From: Neil Horman Date: Fri, 6 Jun 2025 00:57:35 +0000 (-0400) Subject: Fix use of IO::Socket::IP on windows 2025 X-Git-Tag: openssl-3.5.1~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b374f7cb10bd4312f75449b1d01b3264df5ba7d;p=thirdparty%2Fopenssl.git Fix use of IO::Socket::IP on windows 2025 Apparently IO::Socket::IP has several odd behaviors on windows 2025, notably indicating that AF_INET6 isn't a supported family when it clearly is. Follow the pattern in determinig the haveIPV6 variable in Proxy.pm, and record if we determine IPv6 availablity with the IP class or the INET6 class and use the same method when testing port binding Fixes project/#1213 Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte Reviewed-by: Paul Yang (Merged from https://github.com/openssl/openssl/pull/27780) (cherry picked from commit ae404a9b3bd052963b76434bcc97757d1d6d502e) --- diff --git a/util/perl/TLSProxy/Proxy.pm b/util/perl/TLSProxy/Proxy.pm index aaba45b029e..b76f9e931ec 100644 --- a/util/perl/TLSProxy/Proxy.pm +++ b/util/perl/TLSProxy/Proxy.pm @@ -27,6 +27,7 @@ use TLSProxy::NewSessionTicket; use TLSProxy::NextProto; my $have_IPv6; +my $useINET6; my $IP_factory; BEGIN @@ -49,6 +50,7 @@ BEGIN if ($@ eq "") { $IP_factory = sub { IO::Socket::INET6->new(Domain => AF_INET6, @_); }; $have_IPv6 = 1; + $useINET6 = 1; } else { eval { require IO::Socket::IP; @@ -63,9 +65,11 @@ BEGIN if ($@ eq "") { $IP_factory = sub { IO::Socket::IP->new(@_); }; $have_IPv6 = 1; + $useINET6 = 0; } else { $IP_factory = sub { IO::Socket::INET->new(@_); }; $have_IPv6 = 0; + $useINET6 = 0; } } } @@ -113,14 +117,13 @@ sub init for (my $i = 0; $i <= 10; $i++) { $test_client_port = 49152 + int(rand(65535 - 49152)); my $test_sock; - if ($have_IPv6) { - $test_sock = IO::Socket::IP->new(Family => AF_INET6, - LocalPort => $test_client_port, + if ($useINET6 == 0) { + $test_sock = IO::Socket::IP->new(LocalPort => $test_client_port, LocalAddr => $test_client_addr); } else { - $test_sock = IO::Socket::IP->new(Family => AF_INET, - LocalPort => $test_client_port, - LocalAddr => $test_client_addr); + $test_sock = IO::Socket::INET6->new(LocalAddr => $test_client_addr, + LocalPort => $test_client_port, + Domain => AF_INET6); } if ($test_sock) { $found_port = 1; @@ -128,7 +131,7 @@ sub init print "Found available client port ${test_client_port}\n"; last; } - print "Port ${test_client_port} in use. Trying again\n"; + print "Port ${test_client_port} in use - $@\n"; } if ($found_port == 0) {