From 838594642bb15f4971f78528fc253ce29671f15b Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Mon, 19 Nov 2012 00:40:29 -0500 Subject: [PATCH] relay: better error handling and logging detect failures in calls to Net::IP for relayclient entries that don't parse. --- plugins/relay | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/relay b/plugins/relay index 84658cf..7cba450 100644 --- a/plugins/relay +++ b/plugins/relay @@ -149,7 +149,10 @@ sub populate_relayclients { sub is_in_cidr_block { my $self = shift; - my $ip = $self->qp->connection->remote_ip; + my $ip = $self->qp->connection->remote_ip or do { + $self->log(LOGINFO, "err, no remote_ip?"); + return; + }; my $cversion = ip_get_version($ip); for ( @{ $self->{_cidr_blocks} } ) { my ($network, $mask) = ip_splitprefix($_); # split IP & CIDR range @@ -157,7 +160,10 @@ sub is_in_cidr_block { my ($begin, $end) = ip_normalize($_, $rversion); # get pool start/end # expand the client address (zero pad it) before converting to binary - my $bin_ip = ip_iptobin(ip_expand_address($ip, $cversion), $cversion); + my $bin_ip = ip_iptobin(ip_expand_address($ip, $cversion), $cversion) + or next; + + next if ! $begin || ! $end; # probably not a netmask entry if ( ip_bincomp($bin_ip, 'gt', ip_iptobin($begin, $rversion)) && ip_bincomp($bin_ip, 'lt', ip_iptobin($end, $rversion))