Subject: | Protect against getprotobyname() not being available |
Since perl can be built without support for getprotobyname(), either because the system doesn't have the function (as with Android and possibly Blackberry 10) or they were undefined during Configure, Socket.pm should protect the calls to it with an eval {}.
diff --git a/cpan/Socket/Socket.pm b/cpan/Socket/Socket.pm
index 438f11a..167ade3 100644
--- a/cpan/Socket/Socket.pm
+++ b/cpan/Socket/Socket.pm
@@ -998,7 +998,7 @@ sub fake_getaddrinfo
my @ports; # Actually ARRAYrefs of [ socktype, protocol, port ]
my $protname = "";
if( $protocol ) {
- $protname = getprotobynumber( $protocol );
+ $protname = eval { getprotobynumber( $protocol ) };
}
if( $service ne "" and $service !~ m/^\d+$/ ) {
@@ -1029,7 +1029,7 @@ sub fake_getaddrinfo
$port = 0;
}
- push @ports, [ $this_socktype, scalar getprotobyname( $this_protname ) || 0, $port ];
+ push @ports, [ $this_socktype, eval { scalar getprotobyname( $this_protname ) } || 0, $port ];
}
my @ret;