~ubuntu-branches/ubuntu/lucid/mysql-dfsg-5.1/lucid-security

« back to all changes in this revision

Viewing changes to unittest/strings/strings-t.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 22:33:55 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120222223355-or06x1euyk8n0ldi
Tags: 5.1.61-0ubuntu0.10.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496
* Dropped patches unnecessary with 5.1.61:
  - debian/patches/90_mysql_safer_strmov.dpatch
  - debian/patches/51_ssl_test_certs.dpatch
  - debian/patches/52_CVE-2009-4030.dpatch
  - debian/patches/53_CVE-2009-4484.dpatch
  - debian/patches/54_CVE-2008-7247.dpatch
  - debian/patches/55_CVE-2010-1621.dpatch
  - debian/patches/56_CVE-2010-1850.dpatch
  - debian/patches/57_CVE-2010-1849.dpatch
  - debian/patches/58_CVE-2010-1848.dpatch
  - debian/patches/59_CVE-2010-1626.dpatch
  - debian/patches/60_CVE-2010-2008.dpatch
  - debian/patches/60_CVE-2010-3677.dpatch
  - debian/patches/60_CVE-2010-3678.dpatch
  - debian/patches/60_CVE-2010-3679.dpatch
  - debian/patches/60_CVE-2010-3680.dpatch
  - debian/patches/60_CVE-2010-3681.dpatch
  - debian/patches/60_CVE-2010-3682.dpatch
  - debian/patches/60_CVE-2010-3683.dpatch
  - debian/patches/60_CVE-2010-3833.dpatch
  - debian/patches/60_CVE-2010-3834.dpatch
  - debian/patches/60_CVE-2010-3835.dpatch
  - debian/patches/60_CVE-2010-3836.dpatch
  - debian/patches/60_CVE-2010-3837.dpatch
  - debian/patches/60_CVE-2010-3838.dpatch
  - debian/patches/60_CVE-2010-3839.dpatch
  - debian/patches/60_CVE-2010-3840.dpatch
  - debian/patches/61_disable_longfilename_test.dpatch
  - debian/patches/62_alter_table_fix.dpatch
  - debian/patches/63_cherrypick-upstream-49479.dpatch
  - debian/patches/10_readline_build_fix.dpatch
* debian/mysql-client-5.1.docs: removed EXCEPTIONS-CLIENT file
* debian/mysql-server-5.1.docs,debian/libmysqlclient16.docs,
  debian/libmysqlclient-dev.docs: removed, no longer necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
15
 
 
16
#include <tap.h>
 
17
#include <my_global.h>
 
18
#include <my_sys.h>
 
19
 
 
20
 
 
21
/*
 
22
  Test that like_range() returns well-formed results.
 
23
*/
 
24
static int
 
25
test_like_range_for_charset(CHARSET_INFO *cs, const char *src, size_t src_len)
 
26
{
 
27
  char min_str[32], max_str[32];
 
28
  size_t min_len, max_len, min_well_formed_len, max_well_formed_len;
 
29
  int error= 0;
 
30
  
 
31
  cs->coll->like_range(cs, src, src_len, '\\', '_', '%',
 
32
                       sizeof(min_str),  min_str, max_str, &min_len, &max_len);
 
33
  diag("min_len=%d\tmax_len=%d\t%s", (int) min_len, (int) max_len, cs->name);
 
34
  min_well_formed_len= cs->cset->well_formed_len(cs,
 
35
                                                 min_str, min_str + min_len,
 
36
                                                 10000, &error);
 
37
  max_well_formed_len= cs->cset->well_formed_len(cs,
 
38
                                                 max_str, max_str + max_len,
 
39
                                                 10000, &error);
 
40
  if (min_len != min_well_formed_len)
 
41
    diag("Bad min_str: min_well_formed_len=%d min_str[%d]=0x%02X",
 
42
          (int) min_well_formed_len, (int) min_well_formed_len,
 
43
          (uchar) min_str[min_well_formed_len]);
 
44
  if (max_len != max_well_formed_len)
 
45
    diag("Bad max_str: max_well_formed_len=%d max_str[%d]=0x%02X",
 
46
          (int) max_well_formed_len, (int) max_well_formed_len,
 
47
          (uchar) max_str[max_well_formed_len]);
 
48
  return
 
49
    min_len == min_well_formed_len &&
 
50
    max_len == max_well_formed_len ? 0 : 1;
 
51
}
 
52
 
 
53
 
 
54
static CHARSET_INFO *charset_list[]=
 
55
{
 
56
#ifdef HAVE_CHARSET_big5
 
57
  &my_charset_big5_chinese_ci,
 
58
  &my_charset_big5_bin,
 
59
#endif
 
60
#ifdef HAVE_CHARSET_euckr
 
61
  &my_charset_euckr_korean_ci,
 
62
  &my_charset_euckr_bin,
 
63
#endif
 
64
#ifdef HAVE_CHARSET_gb2312
 
65
  &my_charset_gb2312_chinese_ci,
 
66
  &my_charset_gb2312_bin,
 
67
#endif
 
68
#ifdef HAVE_CHARSET_gbk
 
69
  &my_charset_gbk_chinese_ci,
 
70
  &my_charset_gbk_bin,
 
71
#endif
 
72
#ifdef HAVE_CHARSET_latin1
 
73
  &my_charset_latin1,
 
74
  &my_charset_latin1_bin,
 
75
#endif
 
76
#ifdef HAVE_CHARSET_sjis
 
77
  &my_charset_sjis_japanese_ci,
 
78
  &my_charset_sjis_bin,
 
79
#endif
 
80
#ifdef HAVE_CHARSET_tis620
 
81
  &my_charset_tis620_thai_ci,
 
82
  &my_charset_tis620_bin,
 
83
#endif
 
84
#ifdef HAVE_CHARSET_ujis
 
85
  &my_charset_ujis_japanese_ci,
 
86
  &my_charset_ujis_bin,
 
87
#endif
 
88
#ifdef HAVE_CHARSET_utf8
 
89
  &my_charset_utf8_general_ci,
 
90
  &my_charset_utf8_unicode_ci,
 
91
  &my_charset_utf8_bin,
 
92
#endif
 
93
};
 
94
 
 
95
 
 
96
int main()
 
97
{
 
98
  size_t i, failed= 0;
 
99
  
 
100
  plan(1);
 
101
  diag("Testing my_like_range_xxx() functions");
 
102
  
 
103
  for (i= 0; i < array_elements(charset_list); i++)
 
104
  {
 
105
    CHARSET_INFO *cs= charset_list[i];
 
106
    if (test_like_range_for_charset(cs, "abc%", 4))
 
107
    {
 
108
      ++failed;
 
109
      diag("Failed for %s", cs->name);
 
110
    }
 
111
  }
 
112
  ok(failed == 0, "Testing my_like_range_xxx() functions");
 
113
  return exit_status();
 
114
}