Subject: | Data corruption in ->get with $\ set |
If $\ is non-empty, get corrupts fetched files by inserting it at the
end of each block. Attached is a patch fixing the issue.
Subject: | ors-corruption.diff |
diff --git a/lib/Net/SFTP/Foreign.pm b/lib/Net/SFTP/Foreign.pm
index f44bb3d..d5f48da 100644
--- a/lib/Net/SFTP/Foreign.pm
+++ b/lib/Net/SFTP/Foreign.pm
@@ -40,6 +40,7 @@ BEGIN {
sub _hexdump {
no warnings qw(uninitialized);
+ local $\ = '';
my $data = shift;
while ($data =~ /(.{1,32})/smg) {
my $line=$1;
@@ -1784,6 +1785,7 @@ sub get {
}
if (length($data) and !$dont_save) {
+ local $\ = '';
unless (print $fh $data) {
$sftp->_set_error(SFTP_ERR_LOCAL_WRITE_FAILED,
"unable to write data to local file $local", $!);
@@ -1810,6 +1812,7 @@ sub get {
}
if (length($data) and !$dont_save) {
+ local $\ = '';
unless (print $fh $data) {
$sftp->_set_error(SFTP_ERR_LOCAL_WRITE_FAILED,
"unable to write data to local file $local", $!);
@@ -1824,6 +1827,7 @@ sub get {
$cb->($sftp, $data, $askoff + $adjustment, $size + $adjustment);
return undef if $sftp->error;
if (length($data) and !$dont_save) {
+ local $\ = '';
unless (print $fh $data) {
$sftp->_set_error(SFTP_ERR_LOCAL_WRITE_FAILED,
"unable to write data to local file $local", $!);
diff --git a/lib/Net/SFTP/Foreign/Helpers.pm b/lib/Net/SFTP/Foreign/Helpers.pm
index e9e1589..6b7a568 100644
--- a/lib/Net/SFTP/Foreign/Helpers.pm
+++ b/lib/Net/SFTP/Foreign/Helpers.pm
@@ -26,6 +26,7 @@ our @EXPORT = qw( _do_nothing
sub _do_nothing {}
sub _debug {
+ local $\ = "";
if ($Net::SFTP::Foreign::debug & 256) {
print STDERR "#", $$, " ", @_,"\n"
}