X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FAttrib.pm;h=a376c9d1d13c62f36c9f40d668a91a515c4cf045;hp=1c0e2a9aa28e8950b75af0e86867e1f87a3c6a56;hb=f9796d809e6a7d4ed2c356f0f32f1a3d628d3d1f;hpb=fadae1eaa5482a441bc8e8aa829a063ee6a5f0c0 diff --git a/lib/BackupPC/Attrib.pm b/lib/BackupPC/Attrib.pm index 1c0e2a9..a376c9d 100644 --- a/lib/BackupPC/Attrib.pm +++ b/lib/BackupPC/Attrib.pm @@ -12,7 +12,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2001-2003 Craig Barratt +# Copyright (C) 2001-2009 Craig Barratt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ # #======================================================================== # -# Version 3.1.0beta0, released 3 Sep 2007. +# Version 3.2.0, released 31 Jul 2010. # # See http://backuppc.sourceforge.net. # @@ -214,9 +214,9 @@ sub read } (my $magic, $data) = unpack("N a*", $data); if ( $magic != $a->{type} ) { - $a->{_errStr} = sprintf("Wrong magic number in $file" + $a->{_errStr} = sprintf("Wrong magic number in %s" . " (got 0x%x, expected 0x%x)", - $magic, $a->{type}); + $file, $magic, $a->{type}); $fd->close; return; } @@ -252,11 +252,18 @@ sub read $fd->read(\$newData, 65536); $data .= $newData; } - ( - @{$a->{files}{$fileName}}{@FldsUnixW}, - @{$a->{files}{$fileName}}{@FldsUnixN}, - $data - ) = unpack("w$nFldsW N$nFldsN a*", $data); + eval { + ( + @{$a->{files}{$fileName}}{@FldsUnixW}, + @{$a->{files}{$fileName}}{@FldsUnixN}, + $data + ) = unpack("w$nFldsW N$nFldsN a*", $data); + }; + if ( $@ ) { + $a->{_errStr} = "unpack: Can't read attributes for $fileName from $file ($@)"; + $fd->close; + return; + } if ( $a->{files}{$fileName}{$FldsUnixN[-1]} eq "" ) { $a->{_errStr} = "Can't read attributes for $fileName" . " from $file"; @@ -304,7 +311,13 @@ sub write my($data) = $a->writeData; $file = $a->fileName($dir, $file); - mkpath($dir, 0, 0777) if ( !-d $dir ); + if ( !-d $dir ) { + eval { mkpath($dir, 0, 0777) }; + if ( $@ ) { + $a->{_errStr} = "Can't create directory $dir"; + return; + } + } my $fd = BackupPC::FileZIO->open($file, 1, $a->{compress}); if ( !$fd ) { $a->{_errStr} = "Can't open/write to $file";