From: Date: July 20 2007 1:02pm Subject: bk commit into 5.2 tree (bar:1.2538) BUG#29459 List-Archive: http://lists.mysql.com/commits/31220 X-Bug: 29459 Message-Id: <200707201102.l6KB2lPV015842@bar.myoffice.izhnet.ru> Below is the list of changes that have just been committed into a local 5.2 repository of bar. When bar does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-07-20 16:02:43+05:00, bar@stripped +4 -0 Bug#29459 server died handling latin2 collate latin2_czech_cs Problem: sizeof() was errouneously used instead array_elements(), which made the loop access to wrong memory. Fix: changing sizeof() to array_elements(). mysql-test/r/ctype_latin2_ch.result@stripped, 2007-07-20 16:02:41+05:00, bar@stripped +11 -0 Adding test mysql-test/t/ctype_latin2_ch.test@stripped, 2007-07-20 16:02:41+05:00, bar@stripped +12 -0 Adding test strings/ctype-czech.c@stripped, 2007-07-20 16:02:41+05:00, bar@stripped +1 -1 Changing sizeof() to array_elements() strings/ctype-win1250ch.c@stripped, 2007-07-20 16:02:41+05:00, bar@stripped +46 -30 - Changing sizeof() to array_elements() - Changing TAB to spaces - Fixing coding style # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: bar # Host: bar.myoffice.izhnet.ru # Root: /home/bar/mysql-work/mysql-5.2.b29459 --- 1.68/strings/ctype-czech.c 2007-06-21 20:26:24 +05:00 +++ 1.69/strings/ctype-czech.c 2007-07-20 16:02:41 +05:00 @@ -313,7 +313,7 @@ while (1) \ if (value == 255) \ { \ int i; \ - for (i = 0; i < (int) sizeof(doubles); i++) \ + for (i = 0; i < (int) array_elements(doubles); i++) \ { \ const char * pattern = doubles[i].word; \ const char * q = (const char *) p; \ --- 1.60/strings/ctype-win1250ch.c 2007-06-21 14:59:25 +05:00 +++ 1.61/strings/ctype-win1250ch.c 2007-07-20 16:02:41 +05:00 @@ -411,36 +411,52 @@ static struct wordvalue doubles[]= or stop on the primary level */ -#define NEXT_CMP_VALUE(src, p, pass, value, len, ml) \ - while (1) { \ - if (IS_END(p, src, len)) { \ - if (pass == 0 && ml && len > 0) { p= src; pass++; } \ - else { value = 0; break; } \ - } \ - value = ((pass == 0) ? _sort_order_win1250ch1[*p] \ - : _sort_order_win1250ch2[*p]); \ - if (value == 0xff) { \ - int i; \ - for (i = 0; i < (int) sizeof(doubles); i++) { \ - const uchar *patt = doubles[i].word; \ - const uchar *q = (const uchar *) p; \ - while (*patt \ - && !(IS_END(q, src, len)) \ - && (*patt == *q)) { \ - patt++; q++; \ - } \ - if (!(*patt)) { \ - value = (int)((pass == 0) \ - ? doubles[i].pass1 \ - : doubles[i].pass2); \ - p = (const uchar *) q - 1; \ - break; \ - } \ - } \ - } \ - p++; \ - break; \ - } +#define NEXT_CMP_VALUE(src, p, pass, value, len, ml) \ + while (1) \ + { \ + if (IS_END(p, src, len)) \ + { \ + if (pass == 0 && ml && len > 0) \ + { \ + p= src; \ + pass++; \ + } \ + else \ + { \ + value= 0; \ + break; \ + } \ + } \ + value= (pass == 0) ? \ + _sort_order_win1250ch1[*p] : \ + _sort_order_win1250ch2[*p]; \ + if (value == 0xff) \ + { \ + int i; \ + for (i = 0; i < (int) array_elements(doubles); i++) \ + { \ + const uchar *patt= doubles[i].word; \ + const uchar *q= (const uchar *) p; \ + while (*patt && \ + !IS_END(q, src, len) && \ + (*patt == *q)) \ + { \ + patt++; \ + q++; \ + } \ + if (!(*patt)) \ + { \ + value= (int) ((pass == 0) ? \ + doubles[i].pass1 : \ + doubles[i].pass2); \ + p= (const uchar *) q - 1; \ + break; \ + } \ + } \ + } \ + p++; \ + break; \ + } #define IS_END(p, src, len) (((char *)p - (char *)src) >= (len)) --- 1.3/mysql-test/r/ctype_latin2_ch.result 2007-04-03 16:16:07 +05:00 +++ 1.4/mysql-test/r/ctype_latin2_ch.result 2007-07-20 16:02:41 +05:00 @@ -342,3 +342,14 @@ hex(weight_string('a' LEVEL 8)) select hex(weight_string('a' LEVEL 1,8)); hex(weight_string('a' LEVEL 1,8)) 82016100 +create table t1 ( +a varchar(2) character set latin2 collate latin2_czech_cs, +primary key(a) +); +insert into t1 set a=0x5ff; +insert into t1 set a=0xff; +select hex(a) from t1; +hex(a) +05FF +FF +drop table t1; --- 1.3/mysql-test/t/ctype_latin2_ch.test 2007-04-03 16:16:08 +05:00 +++ 1.4/mysql-test/t/ctype_latin2_ch.test 2007-07-20 16:02:41 +05:00 @@ -43,3 +43,15 @@ set names latin2 collate latin2_czech_cs --source include/weight_string_l4.inc --source include/weight_string_l12.inc --source include/weight_string_l14.inc + +# +# Bug#29459 server died handling latin2 collate latin2_czech_cs +# +create table t1 ( + a varchar(2) character set latin2 collate latin2_czech_cs, + primary key(a) +); +insert into t1 set a=0x5ff; +insert into t1 set a=0xff; +select hex(a) from t1; +drop table t1;