Net-SSH-Perl - Re: Bug in Channel.pm when stdin length is just right

Posted on Thu Mar 2 03:29:31 2006 by jongorama in response to 970 (See the whole thread of 6)
Re: Bug in Channel.pm when stdin length is just right
As a quick followup to this - the diffs posted are ambiguous what with the line changes and such. Below you can find a context diff to help you patch Channels.pm, Constants.pm, and SSH2.pm (all from the 1.29 version).
$ diff -c b/Channel.pm ./Channel.pm *** b/Channel.pm 2003-12-03 07:35:21.000000000 -0800 --- ./Channel.pm 2006-02-28 22:00:43.000000000 -0800 *************** *** 189,198 **** --- 189,201 ---- $c->register_handler(SSH2_MSG_CHANNEL_WINDOW_ADJUST, sub { $_[0]->{ssh}->break_client_loop }); + $c->{ssh}->{DoOneLoop} = 10; while ($c->{input}->length) { $c->process_outgoing; $c->{ssh}->client_loop if $c->{input}->length; } + undef( $c->{ssh}->{DoOneLoop} ); + delete $c->{ssh}->{DoOneLoop}; $c->drop_handler(SSH2_MSG_CHANNEL_WINDOW_ADJUST); $c->{ssh}->restore_client_loop; } $ diff -c b/SSH2.pm ./SSH2.pm *** b/SSH2.pm 2005-10-08 14:04:24.000000000 -0700 --- ./SSH2.pm 2006-03-01 17:05:07.340954072 -0800 *************** *** 301,307 **** my $oc = grep { defined } @{ $cmgr->{channels} }; last unless $oc > 1; ! my($rready, $wready) = $select_class->select($rb, $wb); $cmgr->process_input_packets($rready, $wready); for my $a (@$rready) { --- 301,307 ---- my $oc = grep { defined } @{ $cmgr->{channels} }; last unless $oc > 1; ! my($rready, $wready) = $select_class->select($rb, $wb, undef, ($ssh->{DoOneLoop} || undef ) +); $cmgr->process_input_packets($rready, $wready); for my $a (@$rready) { *************** *** 313,318 **** --- 313,319 ---- $ssh->incoming_data->append($buf); } } + last if ($ssh->{DoOneLoop}); } } $ diff -c b/Constants.pm ./Constants.pm *** b/Constants.pm 2001-07-03 00:04:52.000000000 -0700 --- ./Constants.pm 2006-02-28 22:05:34.000000000 -0800 *************** *** 135,141 **** 'PRIVATE_KEY_ID_STRING' => "SSH PRIVATE KEY FILE FORMAT 1.1\n", ! 'MAX_PACKET_SIZE' => 256000, ); use vars qw( %TAGS ); --- 135,142 ---- 'PRIVATE_KEY_ID_STRING' => "SSH PRIVATE KEY FILE FORMAT 1.1\n", ! #'MAX_PACKET_SIZE' => 256000, ! 'MAX_PACKET_SIZE' => 8192, ); use vars qw( %TAGS );
The easiest way to test this is to create two seperate files - one of 32764 bytes, and one of 32765 bytes - and use the 1.29 distro's 'pscp' tool to transfer them to the target node. If you can successfully transfer both files, then the fix is in.
Additionally, note that this fix was tested OK for SSH identifing itself as 'SSH-2.0-OpenSSH_4.2p1 Debian-5'.
Note that while I'm not certian, it's likely that this will resolve the following currently open or new CPAN bugs:
- 17475: Net::SSH::Perl blocks/crashes on IO-Volume > 32kB - 8690: Problem with large stdin to cmd call - 7910: $shh("cat -> file",$data) hangs on large amount of data
...which all appear to be the same thing.
-gilbert.
Direct Responses: 2501 | Write a response