Re: [Ssh-sftp-perl-users] Net SSH2 scp_get/scp_put problems.
Brought to you by:
dbrobins
From: Rutger O. <ov...@us...> - 2006-02-16 19:27:50
|
Saturday, February 11, 2006, 8:18:21 AM, you wrote: RO> But scp_get does not work on files > 25k or so. For a 2k file, it works, but RO> larger files receive a segmentation fault. RO> scp_put just creates a 0 byte file on the remote system but doesn't transfer the contents. I found the scp_get problem; the pv_buffer was being incremented and then accessed at an incorrect position. (Requires a recompile of SSH2.xs). The scp_put problem was patched by by R. Corbridge. stat[2] was being used rather than stat[7] in SSH2.pm. --- diff -r -u Net-SSH2-0.06-orig/SSH2.xs Net-SSH2-0.06/SSH2.xs --- Net-SSH2-0.06-orig/SSH2.xs 2005-11-29 19:54:08.000000000 -0800 +++ Net-SSH2-0.06/SSH2.xs 2006-02-16 11:00:57.000000000 -0800 @@ -1198,7 +1198,7 @@ pv_buffer = sv_grow(buffer, size + 1/*NUL*/); /* force PV */ again: - count = libssh2_channel_read_ex(ch->channel, XLATEXT, pv_buffer, size); + count = libssh2_channel_read_ex(ch->channel, XLATEXT, pv_buffer+total, size); debug("- read %d bytes\n", count); if (count < 0) { @@ -1211,7 +1211,6 @@ total += count; if (count > 0 && (unsigned)count < size) { - pv_buffer += count; size -= count; goto again; } diff -r -u Net-SSH2-0.06-orig/lib/Net/SSH2.pm Net-SSH2-0.06/lib/Net/SSH2.pm --- Net-SSH2-0.06-orig/lib/Net/SSH2.pm 2005-11-19 10:09:54.000000000 -0800 +++ Net-SSH2-0.06/lib/Net/SSH2.pm 2006-02-16 10:39:00.000000000 -0800 @@ -339,7 +339,7 @@ $chan->blocking(1); my $buf; - my $count = $file->sysread($buf, $stat[2]); + my $count = $file->sysread($buf, $stat[7]); $self->error($!, $!), return unless defined $count; $self->error(0, "want $stat[7], have $count"), return unless $count == $stat[7]; |