mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +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;
|
||||
}
|
||||
u8 n = *p;
|
||||
// First subtract base regardless of underflow:
|
||||
if (n < 0x3A) { // 0-9
|
||||
n -= 0x30;
|
||||
}
|
||||
@@ -1485,7 +1486,8 @@ bool DNS::Factory::ptrToIp(const std::string &ptr, sockaddr_storage &ip)
|
||||
else { // invalid
|
||||
return false;
|
||||
}
|
||||
if (n < 0) { // invalid
|
||||
// Now catch any of the underflow conditions above:
|
||||
if (n > 0xf) { // invalid
|
||||
return false;
|
||||
}
|
||||
if (alt == 0) { // high nibble
|
||||
|
||||
Reference in New Issue
Block a user