• unknown's avatar
    Fix Bug #22242 Instance Manager: option-parsing errors · 779d2f16
    unknown authored
    There was a memory overrun, which resulted in safemalloc
    errors. Recommit with post-review fixes.
    
    
    server-tools/instance-manager/instance_options.cc:
      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 problem stemed from the fact that we converted the path to the
      binary, not to the directory. Now we first truncate the path and
      then convert the name of the directory, where the binary resides.
      
      E.g. Suppose that IM got an option --mysqld-path='/usr/local/bin/mysqld'.
      Then convert dirname was called. This routine takes a path to the
      dir (not binary!) and converts it for usage under particular OS.
      And at least for *nixes it *always* adds slash. E.g. for the path above
      convert_dirname() will result in path: '/usr/local/bin/mysqld/'
      Note the last slash. 
      
      The fix is to convert the path to the dir where the binary resides:
      /usr/local/bin/. Then we put back the binary name.
    779d2f16
instance_options.cc 17.1 KB