List:Commits« Previous MessageNext Message »
From:Oystein Grovlen Date:October 20 2010 11:34am
Subject:bzr commit into mysql-5.5 branch (oystein.grovlen:3089) Bug#57512
View as plain text  
#At file:///home/og136792/mysql/mysql-5.5/ based on revid:alexander.nozdrin@stripped

 3089 Oystein Grovlen	2010-10-20
      Bug#57512 str_to_date crash...
      
      str_to_date function should only try to generate a warning for invalid input 
      strings, not when input value is NULL. In latter case, val_str() of input argument
      will return a nil pointer.  Trying to generate a warning using this pointer lead 
      to a segmentation fault. Solution: Only generate warning when pointer to input
      string is non-nil.
     @ mysql-test/r/func_time.result
        Added test case for Bug#57512
     @ mysql-test/t/func_time.test
        Added test case for Bug#57512
     @ sql/item_timefunc.cc
        Skip generating warning when pointer to input string is nil since this implies that
        input argument was NULL.

    modified:
      mysql-test/r/func_time.result
      mysql-test/t/func_time.test
      sql/item_timefunc.cc
=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	2010-09-09 12:02:02 +0000
+++ b/mysql-test/r/func_time.result	2010-10-20 11:34:00 +0000
@@ -1316,3 +1316,12 @@ SELECT 1 FROM t1 ORDER BY @x:=makedate(a
 1
 DROP TABLE t1;
 End of 5.1 tests
+#
+# Bug#57512 str_to_date crash...
+#
+select week(str_to_date(null,0));
+week(str_to_date(null,0))
+NULL
+select subdate(str_to_date(null,0),interval 1 hour);
+subdate(str_to_date(null,0),interval 1 hour)
+NULL

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	2010-08-16 07:11:57 +0000
+++ b/mysql-test/t/func_time.test	2010-10-20 11:34:00 +0000
@@ -833,3 +833,11 @@ SELECT 1 FROM t1 ORDER BY @x:=makedate(a
 DROP TABLE t1;
 
 --echo End of 5.1 tests
+
+--echo #
+--echo # Bug#57512 str_to_date crash...
+--echo #
+
+select week(str_to_date(null,0));
+select subdate(str_to_date(null,0),interval 1 hour);
+

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2010-09-07 06:45:00 +0000
+++ b/sql/item_timefunc.cc	2010-10-20 11:34:00 +0000
@@ -3435,7 +3435,7 @@ bool Item_func_str_to_date::get_date(MYS
   return 0;
 
 null_date:
-  if (fuzzy_date & TIME_NO_ZERO_DATE)
+  if (val && (fuzzy_date & TIME_NO_ZERO_DATE))
   {
     char buff[128];
     strmake(buff, val->ptr(), min(val->length(), sizeof(buff)-1));


Attachment: [text/bzr-bundle] bzr/oystein.grovlen@oracle.com-20101020113400-s73mfr2cbxhbtqsx.bundle
Thread
bzr commit into mysql-5.5 branch (oystein.grovlen:3089) Bug#57512Oystein Grovlen20 Oct
Re: bzr commit into mysql-5.5 branch (oystein.grovlen:3089) Bug#57512Olav Sandstaa20 Oct