diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-04-30 04:43:19 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-04-30 04:43:19 +0000 |
commit | e0f66c8879f54a16ebcacd1e02a38907dc1f54d7 (patch) | |
tree | 402710f5fdf8b052908f91f986520622450a7158 /gnu/usr.bin/perl/ext | |
parent | 7c19333d7f20e7ad25873640ebb85a4de38483f9 (diff) |
Change 5982 by gsar@auger on 2000/04/28 04:48:25
avoid error in IO::Socket::INET when given an unknown service name
with a port number (from Brian Raven <brianr@ssprdmh01.liffe.com>)
Diffstat (limited to 'gnu/usr.bin/perl/ext')
-rw-r--r-- | gnu/usr.bin/perl/ext/IO/lib/IO/Socket/INET.pm | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/gnu/usr.bin/perl/ext/IO/lib/IO/Socket/INET.pm b/gnu/usr.bin/perl/ext/IO/lib/IO/Socket/INET.pm index 27a3d4d847e..c922bf35c95 100644 --- a/gnu/usr.bin/perl/ext/IO/lib/IO/Socket/INET.pm +++ b/gnu/usr.bin/perl/ext/IO/lib/IO/Socket/INET.pm @@ -34,6 +34,7 @@ sub new { sub _sock_info { my($addr,$port,$proto) = @_; + my $origport = $port; my @proto = (); my @serv = (); @@ -59,14 +60,14 @@ sub _sock_info { my $defport = $1 || undef; my $pnum = ($port =~ m,^(\d+)$,)[0]; - if ($port =~ m,\D,) { - unless (@serv = getservbyname($port, $proto[0] || "")) { - $@ = "Bad service '$port'"; - return; - } - } + @serv = getservbyname($port, $proto[0] || "") + if ($port =~ m,\D,); $port = $pnum || $serv[2] || $defport || undef; + unless (defined $port) { + $@ = "Bad service '$origport'"; + return; + } $proto = (getprotobyname($serv[3]))[2] || undef if @serv && !$proto; |