List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:February 10 2011 8:53am
Subject:bzr commit into mysql-trunk branch (Georgi.Kodinov:3631)
View as plain text  
#At file:///Users/kgeorge/mysql/work/B59884-trunk/ based on revid:alexander.barkov@stripped

 3631 Georgi Kodinov	2011-02-10 [merge]
      merge of bug 59884 to mysql-trunk

    modified:
      mysql-test/r/variables.result
      mysql-test/t/variables.test
      mysys/charset.c
=== modified file 'mysql-test/r/variables.result'
--- a/mysql-test/r/variables.result	2010-11-29 16:27:58 +0000
+++ b/mysql-test/r/variables.result	2011-02-10 08:52:44 +0000
@@ -1723,6 +1723,28 @@ drop table t1;
 drop function t1_min;
 drop function t1_max;
 #
+# Bug #59884: setting charset to 2048 crashes
+#
+set session character_set_results = 2048;
+ERROR 42000: Unknown character set: '2048'
+set session character_set_client=2048;
+ERROR 42000: Unknown character set: '2048'
+set session character_set_connection=2048;
+ERROR 42000: Unknown character set: '2048'
+set session character_set_server=2048;
+ERROR 42000: Unknown character set: '2048'
+set session collation_server=2048;
+ERROR HY000: Unknown collation: '2048'
+set session character_set_filesystem=2048;
+ERROR 42000: Unknown character set: '2048'
+set session character_set_database=2048;
+ERROR 42000: Unknown character set: '2048'
+set session collation_connection=2048;
+ERROR HY000: Unknown collation: '2048'
+set session collation_database=2048;
+ERROR HY000: Unknown collation: '2048'
+End of 5.5 tests
+#
 # Bug#57035 'ulonglong sql_mode' stored into ulong, is risky and causes
 #           compiler warning
 #

=== modified file 'mysql-test/t/variables.test'
--- a/mysql-test/t/variables.test	2011-02-02 18:31:39 +0000
+++ b/mysql-test/t/variables.test	2011-02-10 08:52:44 +0000
@@ -1467,6 +1467,32 @@ drop function t1_max;
 
 
 --echo #
+--echo # Bug #59884: setting charset to 2048 crashes
+--echo #
+
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_results = 2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_client=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_connection=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_server=2048;
+--error ER_UNKNOWN_COLLATION
+set session collation_server=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_filesystem=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_database=2048;
+--error ER_UNKNOWN_COLLATION
+set session collation_connection=2048;
+--error ER_UNKNOWN_COLLATION
+set session collation_database=2048;
+
+--echo End of 5.5 tests
+
+
+--echo #
 --echo # Bug#57035 'ulonglong sql_mode' stored into ulong, is risky and causes
 --echo #           compiler warning
 --echo #

=== modified file 'mysys/charset.c'
--- a/mysys/charset.c	2010-12-20 10:28:06 +0000
+++ b/mysys/charset.c	2011-02-10 08:52:44 +0000
@@ -472,6 +472,7 @@ CHARSET_INFO *default_charset_info = &my
 
 void add_compiled_collation(CHARSET_INFO *cs)
 {
+  DBUG_ASSERT(cs->number < array_elements(all_charsets));
   all_charsets[cs->number]= cs;
   cs->state|= MY_CS_AVAILABLE;
 }
@@ -579,14 +580,17 @@ uint get_charset_number(const char *char
 
 const char *get_charset_name(uint charset_number)
 {
-  CHARSET_INFO *cs;
   my_pthread_once(&charsets_initialized, init_available_charsets);
 
-  cs=all_charsets[charset_number];
-  if (cs && (cs->number == charset_number) && cs->name )
-    return (char*) cs->name;
+  if (charset_number < array_elements(all_charsets))
+  {
+    CHARSET_INFO *cs= all_charsets[charset_number];
+
+    if (cs && (cs->number == charset_number) && cs->name)
+      return (char*) cs->name;
+  }
   
-  return (char*) "?";   /* this mimics find_type() */
+  return "?";   /* this mimics find_type() */
 }
 
 
@@ -596,6 +600,8 @@ get_internal_charset(MY_CHARSET_LOADER *
   char  buf[FN_REFLEN];
   CHARSET_INFO *cs;
 
+  DBUG_ASSERT(cs_number < array_elements(all_charsets));
+
   if ((cs= all_charsets[cs_number]))
   {
     if (cs->state & MY_CS_READY)  /* if CS is already initialized */
@@ -646,8 +652,8 @@ CHARSET_INFO *get_charset(uint cs_number
     return default_charset_info;
 
   my_pthread_once(&charsets_initialized, init_available_charsets);
-  
-  if (!cs_number || cs_number > array_elements(all_charsets))
+ 
+  if (cs_number >= array_elements(all_charsets)) 
     return NULL;
 
   my_charset_loader_init_mysys(&loader);

No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
Thread
bzr commit into mysql-trunk branch (Georgi.Kodinov:3631) Georgi Kodinov10 Feb