List:Commits« Previous MessageNext Message »
From:Nirbhay Choubey Date:January 13 2011 10:26am
Subject:bzr commit into mysql-5.1 branch (nirbhay.choubey:3549) Bug#59109
View as plain text  
#At file:///home/nirbhay/Project/mysql/repo/bugs/source/mysql-5.1-59109/ based on revid:georgi.kodinov@stripped

 3549 Nirbhay Choubey	2011-01-13
      Bug#59109 : mysqlslap crashes on mysql_fetch_row after ignoring
                  null from mysql_store_result.
      
      mysqlslap segfaults at a point when it tries to fetch rows from
      the result set.
      
      Under some circumstances, mysql_store_result can return 'NULL',
      even after query execution (mysql_query) succeeds, and eventually
      a segfault might occur if same unchecked return value is passed
      to mysql_fetch_row.
      
      Fixed by adding a check on mysql_store_result's return value.
     @ client/mysqlslap.c
        Bug#59109 : mysqlslap crashes on mysql_fetch_row after ignoring
                    null from mysql_store_result.
        
        Added a check on mysql_store_result's return value. A 'NULL' return
        value here shows an erroneous situation as mysql_field_count has already
        reported a non-zero value.

    modified:
      client/mysqlslap.c
=== modified file 'client/mysqlslap.c'
--- a/client/mysqlslap.c	2010-06-10 20:16:43 +0000
+++ b/client/mysqlslap.c	2011-01-13 10:26:42 +0000
@@ -1519,7 +1519,12 @@ generate_primary_key_list(MYSQL *mysql, 
       exit(1);
     }
 
-    result= mysql_store_result(mysql);
+    if (!(result= mysql_store_result(mysql)))
+    {
+      fprintf(stderr, "%s: Error when storing result: %d %s\n",
+              my_progname, mysql_errno(mysql), mysql_error(mysql));
+      exit(1);
+    }
     primary_keys_number_of= mysql_num_rows(result);
 
     /* So why check this? Blackhole :) */
@@ -1891,10 +1896,15 @@ limit_not_met:
       {
         if (mysql_field_count(mysql))
         {
-          result= mysql_store_result(mysql);
-          while ((row = mysql_fetch_row(result)))
-            counter++;
-          mysql_free_result(result);
+          if (!(result= mysql_store_result(mysql)))
+            fprintf(stderr, "%s: Error when storing result: %d %s\n",
+                    my_progname, mysql_errno(mysql), mysql_error(mysql));
+          else
+          {
+            while ((row= mysql_fetch_row(result)))
+              counter++;
+            mysql_free_result(result);
+          }
         }
       } while(mysql_next_result(mysql) == 0);
       queries++;


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-5.1 branch (nirbhay.choubey:3549) Bug#59109Nirbhay Choubey13 Jan