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

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