68a45c
From 47d2c70bde8c0bdc67e85578133338fc63c33f13 Mon Sep 17 00:00:00 2001
68a45c
From: Jitka Plesnikova <jplesnik@redhat.com>
68a45c
Date: Thu, 17 Jun 2021 11:41:48 +0200
68a45c
Subject: [PATCH 2/2] Fix _resolv return value
68a45c
68a45c
in case of the new warnings.
68a45c
Thanks to @nlv02636
68a45c
68a45c
Backported fromn Net-Ping 2.68
68a45c
---
68a45c
 dist/Net-Ping/lib/Net/Ping.pm | 8 +++++++-
68a45c
 1 file changed, 7 insertions(+), 1 deletion(-)
68a45c
68a45c
diff --git a/dist/Net-Ping/lib/Net/Ping.pm b/dist/Net-Ping/lib/Net/Ping.pm
68a45c
index 9e2497c..87087fc 100644
68a45c
--- a/dist/Net-Ping/lib/Net/Ping.pm
68a45c
+++ b/dist/Net-Ping/lib/Net/Ping.pm
68a45c
@@ -1794,6 +1794,7 @@ sub _resolv {
68a45c
   # Clean up port
68a45c
   if (defined($h{port}) && (($h{port} !~ /^\d{1,5}$/) || ($h{port} < 1) || ($h{port} > 65535))) {
68a45c
     croak("Invalid port `$h{port}' in `$name'");
68a45c
+    return undef;
68a45c
   }
68a45c
 # END - host:port
68a45c
 
68a45c
@@ -1850,18 +1851,21 @@ sub _resolv {
68a45c
         } else {
68a45c
           (undef, $h{addr_in}, undef, undef) = Socket::unpack_sockaddr_in6 $getaddr[0]->{addr};
68a45c
         }
68a45c
-        return \%h
68a45c
+        return \%h;
68a45c
       } else {
68a45c
         carp("getnameinfo($getaddr[0]->{addr}) failed - $err");
68a45c
+        return undef;
68a45c
       }
68a45c
     } else {
68a45c
       warn(sprintf("getaddrinfo($h{host},,%s) failed - $err",
68a45c
                     $family == AF_INET ? "AF_INET" : "AF_INET6"));
68a45c
+      return undef;
68a45c
     }
68a45c
   # old way
68a45c
   } else {
68a45c
     if ($family == $AF_INET6) {
68a45c
       croak("Socket >= 1.94 required for IPv6 - found Socket $Socket::VERSION");
68a45c
+      return undef;
68a45c
     }
68a45c
 
68a45c
     my @gethost = gethostbyname($h{host});
68a45c
@@ -1872,8 +1876,10 @@ sub _resolv {
68a45c
       return \%h
68a45c
     } else {
68a45c
       carp("gethostbyname($h{host}) failed - $^E");
68a45c
+      return undef;
68a45c
     }
68a45c
   }
68a45c
+  return undef;
68a45c
 }
68a45c
 
68a45c
 sub _pack_sockaddr_in($$) {
68a45c
-- 
68a45c
2.31.1
68a45c