[monitoring-plugins] use pack_sockaddr_in rather than hand-rolled
RincewindsHat
git at monitoring-plugins.org
Fri Oct 6 11:40:12 CEST 2023
Module: monitoring-plugins
Branch: master
Commit: c2f20fdd94feb06e815a891b22f25fac10c2cc13
Author: Stuart Henderson <stu at spacehopper.org>
Committer: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com>
Date: Fri Jan 27 12:56:11 2017 +0000
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=c2f20fd
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(-)
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl
index 84f2022..4822fe6 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"};
More information about the Commits
mailing list