List:Commits« Previous MessageNext Message »
From:Petr Chardin Date:November 8 2006 3:57pm
Subject:bk commit into 5.1 tree (petr:1.2343) BUG#22242
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of cps. When cps does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-11-08 18:57:37+03:00, petr@stripped +1 -0
  Fix Bug #22242 Instance Manager: option-parsing errors
  
  There was a memory overrun, which resulted in safemalloc
  errors.

  server-tools/instance-manager/instance_options.cc@stripped, 2006-11-08 18:57:35+03:00, petr@stripped +22 -5
    Memory was overrun here: convert_dirname() adds a slash to the
    end of the string. then it was removed (with end[-1]=0), but
    the overrun still happened, which caused sefemalloc to complain.
    
    The fix is to convert the path to mysqld rather then to the
    binary itself.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	petr
# Host:	outpost.site
# Root:	/home/cps/mysql/trees/mysql-5.1-runtime

--- 1.38/server-tools/instance-manager/instance_options.cc	2006-11-01 20:41:04 +03:00
+++ 1.39/server-tools/instance-manager/instance_options.cc	2006-11-08 18:57:35 +03:00
@@ -423,17 +423,34 @@
 
   if (!mysqld_path.str)
   {
-    // Need one extra byte, as convert_dirname() adds a slash at the end.
-    if (!(mysqld_path.str= alloc_root(&alloc, strlen(default_path) + 2)))
+    /*
+      Need to copy the path to allocated memory, as convert_dirname() might
+      need to change it
+    */
+    if (!(mysqld_path.str= alloc_root(&alloc, strlen(default_path) + 1)))
       goto err;
     strcpy(mysqld_path.str, default_path);
   }
 
-  // it's safe to cast this to char* since this is a buffer we are allocating
+  mysqld_path.length= strlen(mysqld_path.str);
+
+  /*
+    Below we will conver the path to mysqld in the case, it was given
+    in a format of another OS (e.g. uses '/' instead of '\' etc).
+    Here we strip the path to get rid of the binary name ("mysqld"),
+    we do it by setting 'm' character to 0 and then put it back
+  */
+  if (mysqld_path.length >  6  &&
+      strncpy(mysqld_path.str + mysqld_path.length - 6, "mysqld", 6))
+    mysqld_path.str[mysqld_path.length - 6] =0; //remove 'm letter'
+  else
+    goto err;
+
+  /* convert dirname to the format of current OS */
   end= convert_dirname((char*)mysqld_path.str, mysqld_path.str, NullS);
-  end[-1]= 0;
 
-  mysqld_path.length= strlen(mysqld_path.str);
+  /* put back 'm' character */
+  mysqld_path.str[mysqld_path.length - 6] ='m';
 
   if (mysqld_port)
     mysqld_port_val= atoi(mysqld_port);
Thread
bk commit into 5.1 tree (petr:1.2343) BUG#22242Petr Chardin8 Nov