Incorporate upstream fix for getaddrinfo handling
Closes: #947921
Small adjustments from upstream commits were needed, similar to the ones for the patches attached to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=947921#5 for buster.
I manually tested the resulting package using a procedure similar to the one in the log of debian/patches/ping-try-next-addrinfo-on-connect-failure.patch (and the corresponding upstream commit).