From 441da2f2457240ceb9fde18cf159a57b09deb375 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Tue, 29 Jan 2013 23:31:39 +0100 Subject: [PATCH] Also restrict cidrlen for testmask/masktrace (match_ips()). --- src/match.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/match.c b/src/match.c index 29722c9c..5c07c34a 100644 --- a/src/match.c +++ b/src/match.c @@ -368,12 +368,15 @@ int match_ips(const char *s1, const char *s2) *len++ = '\0'; cidrlen = atoi(len); - if (cidrlen == 0) + if (cidrlen <= 0) return 0; #ifdef RB_IPV6 if (strchr(mask, ':') && strchr(address, ':')) { + if (cidrlen > 128) + return 0; + aftype = AF_INET6; ipptr = &((struct sockaddr_in6 *)&ipaddr)->sin6_addr; maskptr = &((struct sockaddr_in6 *)&maskaddr)->sin6_addr; @@ -382,6 +385,9 @@ int match_ips(const char *s1, const char *s2) #endif if (!strchr(mask, ':') && !strchr(address, ':')) { + if (cidrlen > 32) + return 0; + aftype = AF_INET; ipptr = &((struct sockaddr_in *)&ipaddr)->sin_addr; maskptr = &((struct sockaddr_in *)&maskaddr)->sin_addr;