mirror of
https://github.com/matrix-construct/construct
synced 2025-01-16 17:46:54 +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';
|
*len++ = '\0';
|
||||||
|
|
||||||
cidrlen = atoi(len);
|
cidrlen = atoi(len);
|
||||||
if (cidrlen == 0)
|
if (cidrlen <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#ifdef RB_IPV6
|
#ifdef RB_IPV6
|
||||||
if (strchr(mask, ':') && strchr(address, ':'))
|
if (strchr(mask, ':') && strchr(address, ':'))
|
||||||
{
|
{
|
||||||
|
if (cidrlen > 128)
|
||||||
|
return 0;
|
||||||
|
|
||||||
aftype = AF_INET6;
|
aftype = AF_INET6;
|
||||||
ipptr = &((struct sockaddr_in6 *)&ipaddr)->sin6_addr;
|
ipptr = &((struct sockaddr_in6 *)&ipaddr)->sin6_addr;
|
||||||
maskptr = &((struct sockaddr_in6 *)&maskaddr)->sin6_addr;
|
maskptr = &((struct sockaddr_in6 *)&maskaddr)->sin6_addr;
|
||||||
|
@ -382,6 +385,9 @@ int match_ips(const char *s1, const char *s2)
|
||||||
#endif
|
#endif
|
||||||
if (!strchr(mask, ':') && !strchr(address, ':'))
|
if (!strchr(mask, ':') && !strchr(address, ':'))
|
||||||
{
|
{
|
||||||
|
if (cidrlen > 32)
|
||||||
|
return 0;
|
||||||
|
|
||||||
aftype = AF_INET;
|
aftype = AF_INET;
|
||||||
ipptr = &((struct sockaddr_in *)&ipaddr)->sin_addr;
|
ipptr = &((struct sockaddr_in *)&ipaddr)->sin_addr;
|
||||||
maskptr = &((struct sockaddr_in *)&maskaddr)->sin_addr;
|
maskptr = &((struct sockaddr_in *)&maskaddr)->sin_addr;
|
||||||
|
|
Loading…
Add table
Reference in a new issue