mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Correctly check for unsigned subtraction underflow.
This commit is contained in:
@@ -1473,6 +1473,7 @@ bool DNS::Factory::ptrToIp(const std::string &ptr, sockaddr_storage &ip)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
u8 n = *p;
|
u8 n = *p;
|
||||||
|
// First subtract base regardless of underflow:
|
||||||
if (n < 0x3A) { // 0-9
|
if (n < 0x3A) { // 0-9
|
||||||
n -= 0x30;
|
n -= 0x30;
|
||||||
}
|
}
|
||||||
@@ -1485,7 +1486,8 @@ bool DNS::Factory::ptrToIp(const std::string &ptr, sockaddr_storage &ip)
|
|||||||
else { // invalid
|
else { // invalid
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (n < 0) { // invalid
|
// Now catch any of the underflow conditions above:
|
||||||
|
if (n > 0xf) { // invalid
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (alt == 0) { // high nibble
|
if (alt == 0) { // high nibble
|
||||||
|
|||||||
Reference in New Issue
Block a user