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