summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <tnurnberg@salvation.intern.azundris.com>2006-09-04 09:13:40 +0200
committerunknown <tnurnberg@salvation.intern.azundris.com>2006-09-04 09:13:40 +0200
commit52f3977eef283130b2d281a4f79353c04412cd92 (patch)
treec7039cec08667391b6eac2780670c33d5b05f669 /sql
parent76f65b3fb38d45dbd8b954cc2ded383d6179e13d (diff)
downloadmariadb-git-52f3977eef283130b2d281a4f79353c04412cd92.tar.gz
Bug#21913: DATE_FORMAT() Crashes mysql server if I use it through mysql-connector-j driver.
Variable character_set_results can legally be NULL (for "no conversion.") This could result in a NULL deref that crashed the server. Fixed. (Although ran some additional precursory tests to see whether I could break anything else, but no breakage so far.) mysql-test/r/func_time.result: Bug#21913: DATE_FORMAT() Crashes mysql server if I use it through mysql-connector-j driver. Prove DATE_FORMAT() no longer crashes the server when character_set_results is NULL (which is a legal value and means, "no conversion"). mysql-test/t/func_time.test: Bug#21913: DATE_FORMAT() Crashes mysql server if I use it through mysql-connector-j driver. Prove DATE_FORMAT() no longer crashes the server when character_set_results is NULL (which is a legal value and means, "no conversion"). sql/sql_string.cc: Bug#21913: DATE_FORMAT() Crashes mysql server if I use it through mysql-connector-j driver. Avoid NULL deref in my_charset_same() -- if !to_cs, we won't need to compare because it is magic for, "no conversion."
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_string.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 939ffe8d9d2..aaa85b0d96c 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -248,6 +248,10 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
0 No conversion needed
1 Either character set conversion or adding leading zeros
(e.g. for UCS-2) must be done
+
+ NOTE
+ to_cs may be NULL for "no conversion" if the system variable
+ character_set_results is NULL.
*/
bool String::needs_conversion(uint32 arg_length,
@@ -256,7 +260,8 @@ bool String::needs_conversion(uint32 arg_length,
uint32 *offset)
{
*offset= 0;
- if ((to_cs == &my_charset_bin) ||
+ if (!to_cs ||
+ (to_cs == &my_charset_bin) ||
(to_cs == from_cs) ||
my_charset_same(from_cs, to_cs) ||
((from_cs == &my_charset_bin) &&