Blame SOURCES/mysql-connector-odbc-cond.patch

f037f8
When looking for a terminating null character that isn't there and apparently
f037f8
isn't supposed to be there as the length of the string is kept in a separate
f037f8
variable. The code then tries to avoid a disaster by doing the right test after
f037f8
it has done the wrong test, but with a bit of bad luck the out-of-bounds read
f037f8
could cause a segmentation fault. Even if the error wouldn't affect the
f037f8
operation of the code, fixing it will save programmers from wasting their time
f037f8
chasing false alarms.
f037f8
f037f8
This patch reverses the order of the two tests. I suppose checking for null
f037f8
characters is OK as an additional safety measure, but it needs to be done
f037f8
conditionally after the length test to avoid an out-of-bounds read.
f037f8
f037f8
Upstream bug report: http://bugs.mysql.com/bug.php?id=64105
f037f8
f037f8
diff -up mysql-connector-odbc-5.2.5-src/util/stringutil.c.cond mysql-connector-odbc-5.2.5-src/util/stringutil.c
f037f8
--- mysql-connector-odbc-5.2.5-src/util/stringutil.c.cond	2013-06-17 08:45:54.382640969 +0200
f037f8
+++ mysql-connector-odbc-5.2.5-src/util/stringutil.c	2013-06-17 08:45:58.084640903 +0200
f037f8
@@ -94,7 +94,7 @@ SQLWCHAR *sqlchar_as_sqlwchar(CHARSET_IN
f037f8
     return NULL;
f037f8
   }
f037f8
 
f037f8
-  for (pos= str, i= 0; *pos && pos < str_end; )
f037f8
+  for (pos= str, i= 0; pos < str_end && *pos; )
f037f8
   {
f037f8
     if (sizeof(SQLWCHAR) == 4)
f037f8
     {