read on an SFTP file is segfaulting on line 1562 of SSH2.xs
fi->sf seems to be an invalid memory address.
version of libssh2 is 0.18
Attached a simple test case.
--
Rafael
Subject: | segfault.t |
#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH2;
chomp(my $host = do { print "Enter SFTP host: "; scalar <> });
chomp(my $user = do { print "Enter SFTP user: "; scalar <> });
chomp(my $pass = do { print "Enter SFTP password: "; scalar <> });
chomp(my $path = do { print "Enter remote directory: "; scalar <> });
my $ssh = Net::SSH2->new;
$ssh->connect($host);
$ssh->auth_password($user, $pass);
my $sftp = $ssh->sftp;
my $dir = $sftp->opendir($path);
while (my $file = $dir->read) {
my $name = $file->{name};
next if $name =~ /^..?\z/;
my $in = $sftp->open("$path/$name");
# This segfaults.
$in->read(my $buf, 4096);
}