Subject: | Bad arg length for Socket::sockaddr_family |
Date: | Thu, 8 Aug 2019 13:42:01 +0200 |
To: | bug-IO-Socket-SSL [...] rt.cpan.org |
From: | Jonny Schulz <jonny [...] sevenmail.net> |
Hello together,
the IO::Socket::SSL module in Debian Buster has the issue, that peeraddr/peerhost is empty or throwing an error if the client closing the connection after accept(). That happends not if I use IO::Socket::INET.
Here is the example code:
---
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket::SSL;
use IO::Socket::INET;
my $sock = IO::Socket::SSL->new(
Listen => 5,
LocalAddr => "127.0.0.1",
Proto => 'tcp',
SSL_cert_file => 'server.cert',
SSL_key_file => 'server.key',
) or die $!;
my $port = $sock->sockport;
my $pid = fork;
if ($pid) {
my $client = $sock->accept;
sleep 1; # socket will be closed in this time
print "peerhost = ", $client->peerhost, "\n";
print "peeraddr = ", $client->peeraddr, "\n";
} else {
my $sock = IO::Socket::SSL->new(
PeerAddr => "127.0.0.1",
PeerPort => $port,
Proto => 'tcp',
SSL_verify_mode => SSL_VERIFY_NONE
) or die $!;
$sock->close();
}
---
Output:
Use of uninitialized value in print at test-ssl.pl line 21.
peerhost =
Use of uninitialized value in subroutine entry at /usr/share/perl/5.28/IO/Socket/IP.pm line 541.
Bad arg length for Socket::sockaddr_family, length is 0, should be at least 2 at /usr/share/perl/5.28/IO/Socket/IP.pm line 541.
Regards
Jonny