best way to test for integer in [16;31]

This commit is contained in:
Thomas Bernard 2019-04-23 14:19:31 +02:00
parent 60ed85fe70
commit f3a567cedf
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
1 changed files with 1 additions and 2 deletions

View File

@ -85,8 +85,7 @@ static int is_rfc1918addr(const char * addr)
return 1; return 1;
/* 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) */ /* 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) */
if(COMPARE(addr, "172.")) { if(COMPARE(addr, "172.")) {
int i = atoi(addr + 4); if((atoi(addr + 4) | 0x0f) == 0x1f)
if((16 <= i) && (i <= 31))
return 1; return 1;
} }
return 0; return 0;