Change 7529 by jhi@alpha on 2000/11/02 17:58:08

	recv() can fail and return undef.
	
	Subject: [ID 20001102.003] Net::Ping patch: "Bad arg lenght" error appears if host is unreachable    
	From: "Alexey V. Barantsev" <barancev@kazbek.ispras.ru>
	Date: Thu, 2 Nov 2000 20:12:20 +0300
	Message-Id: <200011021712.UAA07919@dallas.kazbek.ispras.ru>

Affected files ...

... //depot/perl/lib/Net/Ping.pm#12 edit

Differences ...

==== //depot/perl/lib/Net/Ping.pm#12 (text) ====
Index: perl/lib/Net/Ping.pm
--- perl/lib/Net/Ping.pm.~1~	Thu Nov 22 14:37:52 2001
+++ perl/lib/Net/Ping.pm	Thu Nov 22 14:37:52 2001
@@ -369,16 +369,17 @@
         elsif ($nfound)         # A packet is waiting
         {
             $from_msg = "";
-            $from_saddr = recv($self->{"fh"}, $from_msg, 1500, $flags);
-            ($from_port, $from_ip) = sockaddr_in($from_saddr);
-            if (($from_ip eq $ip) &&        # Does the packet check out?
-                ($from_port == $self->{"port_num"}) &&
-                ($from_msg eq $msg))
-            {
-                $ret = 1;       # It's a winner
-                $done = 1;
-            }
-        }
+            $from_saddr = recv($self->{"fh"}, $from_msg, 1500, $flags)
+		or last; # For example an unreachable host will make recv() fail.
+	    ($from_port, $from_ip) = sockaddr_in($from_saddr);
+	    if (($from_ip eq $ip) &&        # Does the packet check out?
+		($from_port == $self->{"port_num"}) &&
+		($from_msg eq $msg))
+	    {
+		$ret = 1;       # It's a winner
+		$done = 1;
+	    }
+	}
         else                    # Oops, timed out
         {
             $done = 1;
End of Patch.
