From c2f20fdd94feb06e815a891b22f25fac10c2cc13 Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Fri, 27 Jan 2017 12:56:11 +0000 Subject: use pack_sockaddr_in rather than hand-rolled On some OS, sockaddr structs include a length field. Perl's pack_sockaddr_in takes this into account; the hand-rolled "pack('S n a4 x8'..." doesn't do so, resulting in connection failures. --- plugins-scripts/check_ircd.pl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl index 84f20229..4822fe68 100755 --- a/plugins-scripts/check_ircd.pl +++ b/plugins-scripts/check_ircd.pl @@ -146,7 +146,6 @@ sub bindRemote ($$) { my ($in_remotehost, $in_remoteport) = @_; my $proto = getprotobyname('tcp'); - my $sockaddr; my $that; my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); @@ -154,8 +153,7 @@ sub bindRemote ($$) print "IRCD UNKNOWN: Could not start socket ($!)\n"; exit $ERRORS{"UNKNOWN"}; } - $sockaddr = 'S n a4 x8'; - $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr); + $that = pack_sockaddr_in ($in_remoteport, $thataddr); if (!connect(ClientSocket, $that)) { print "IRCD UNKNOWN: Could not connect socket ($!)\n"; exit $ERRORS{"UNKNOWN"}; -- cgit v1.2.3-74-g34f1