BackupPC-users

Re: [BackupPC-users] jLib bug with md5sum stuff

2010-12-07 00:50:37
Subject: Re: [BackupPC-users] jLib bug with md5sum stuff
From: Robin Lee Powell <rlpowell AT digitalkingdom DOT org>
To: BackupPC Users <backuppc-users AT lists.sourceforge DOT net>, backuppc AT kosowsky DOT org
Date: Mon, 6 Dec 2010 21:48:17 -0800
On Mon, Dec 06, 2010 at 12:32:01PM -0800, Robin Lee Powell wrote:
> 
> substr outside of string at /usr/local/lib64/BackupPC/jLib.pm line 162.
> Use of uninitialized value in concatenation (.) or string at 
> /usr/local/lib64/BackupPC/jLib.pm line 162.
> 
> The line(s) in question:
> 
>             $datalast = substr($data[($i-1)%2], $rsize, _128KB-$rsize)
>                         . substr($data[$i%2], 0 ,$rsize);
> 
> in zFile2MD5
> 
> I have no idea how that could happen.  -_-  Will help debug any way
> requested.

Had to figure it out sooner rather than later.  :)

It happens when a file is > 128KiB but < 256KiB, so only one buffer
is full.  Fix:

--- /tmp/jLib.pm        2010-12-07 05:47:42.086646699 +0000
+++ /usr/local/lib64/BackupPC/jLib.pm   2010-12-07 05:46:55.108231972 +0000
@@ -159,8 +159,8 @@
                while ( ($rsize = $fh->read(\$data[(++$i)%2], _128KB)) == _128KB
                        &&  ($totsize += $rsize) < _1MB) {}
                $totsize +=$rsize if $rsize < _128KB; # Add back in partial read
-           $datalast = ( $data[($i-1)%2] ? substr($data[($i-1)%2], $rsize, 
_128KB-$rsize) : '' )
-                       . ( $data[$i%2] ? substr($data[$i%2], 0 ,$rsize) : '' );
+           $datalast = substr($data[($i-1)%2], $rsize, _128KB-$rsize)
+                       . substr($data[$i%2], 0 ,$rsize);
     }
     $filesize = $totsize if $totsize < _1MB; #Already know the size because 
read it all
     if ($filesize == 0) { # Try to find size from attrib file


-Robin

-- 
http://singinst.org/ :  Our last, best hope for a fantastic future.
Lojban (http://www.lojban.org/): The language in which "this parrot
is dead" is "ti poi spitaki cu morsi", but "this sentence is false"
is "na nei".   My personal page: http://www.digitalkingdom.org/rlp/

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/

<Prev in Thread] Current Thread [Next in Thread>