From e2faec5f111fd733b56f8842cb50998cefccd926 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sat, 1 Jun 2013 13:34:05 -0700 Subject: Fix is_ipv4_broadcast() behaviour, don't return success for addresses that can't be broadcast by definition (IPv6, IPv4 p-t-p). --- src/ipaddrcheck_functions.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/ipaddrcheck_functions.c') diff --git a/src/ipaddrcheck_functions.c b/src/ipaddrcheck_functions.c index 061ba8f..2ba8de2 100644 --- a/src/ipaddrcheck_functions.c +++ b/src/ipaddrcheck_functions.c @@ -244,7 +244,11 @@ int is_ipv4_broadcast(CIDR *address) { int result; - if( cidr_equals(address, cidr_addr_broadcast(address)) == 0 ) + /* The very concept of broadcast address doesn't apply to + IPv6 and point-to-point or /32 IPv4 */ + if( (cidr_get_proto(address) == CIDR_IPV4) && + (cidr_equals(address, cidr_addr_broadcast(address)) == 0 ) && + (cidr_get_pflen(address) < 31) ) { result = RESULT_SUCCESS; } -- cgit v1.2.3