mirror of
https://github.com/matrix-construct/construct
synced 2024-12-28 08:24:08 +01:00
Also restrict cidrlen for testmask/masktrace (match_ips()).
This commit is contained in:
parent
4dbd5e07ad
commit
441da2f245
1 changed files with 7 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue