Results 1 to 2 of 2

Thread: mysql-zrm-restore does not check for running out of disk space

  1. #1
    Join Date
    May 2013
    Posts
    5

    Default mysql-zrm-restore does not check for running out of disk space

    In extractToTmpFile(), there are no checks if the writes to the temp file succeeds or not. It will happily continue trying to restore from a truncated file if the tmpdir is not large enough to hold the file. It needs to abort on errors.

  2. #2
    Join Date
    May 2013
    Posts
    5

    Default patch

    Code:
    diff -up MySQL-zrm-3.0/usr/bin/mysql-zrm-restore.tmpwrite MySQL-zrm-3.0/usr/bin/mysql-zrm-restore
    --- MySQL-zrm-3.0/usr/bin/mysql-zrm-restore.tmpwrite    2013-08-26 14:45:36.000000000 -0600
    +++ MySQL-zrm-3.0/usr/bin/mysql-zrm-restore     2014-03-19 16:13:17.360910775 -0600
    @@ -415,7 +415,7 @@ sub extractToTmpFile()
             $dbs =~s/\s/|/g;
             open( MSQL, $sqlmaster ) or &printAndDie( "Could not open file $sqlmaster $!\n" );
            my $tf = tmpnam();
    -        open(OF,">$tf" ) or &printAndDie( "Coupld not open tmp file $tf $!\n" );
    +        open(OF,">$tf" ) or &printAndDie( "Could not open tmp file $tf $!\n" );
             my $found = 0;
             while(<MSQL>){
                     if( /^-- Current Database: / ){
    @@ -425,10 +425,18 @@ sub extractToTmpFile()
                             $found = /\`($dbs)\`/ ? 1:0;
                     }
                     if( $found ){
    -                        print OF $_;
    +                        if ( ! print OF $_ ) {
    +                                my $r = "$!";
    +                                unlink( $tf );
    +                                &printAndDie( "Could not write to tmp file $tf $r\n" );
    +                        }
                     }elsif( /^\/\*\!\d*\s*SET / ){
                             # Also print if statement is "/*! SET "
    -                        print OF $_;
    +                        if ( ! print OF $_ ) {
    +                                my $r = "$!";
    +                                unlink( $tf );
    +                                &printAndDie( "Could not write to tmp file $tf $r\n" );
    +                        }
                     }
             }
             close( OF );

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •