mirror of
https://github.com/nginx/nginx.git
synced 2025-06-08 02:02:38 +08:00
Fixed overflow detection in ngx_inet_addr().
Overflow detection of the last octet might not work. Reported by Sergey Polovko.
This commit is contained in:
parent
8568baef1f
commit
89ad9ea309
@ -26,15 +26,15 @@ ngx_inet_addr(u_char *text, size_t len)
|
|||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
for (p = text; p < text + len; p++) {
|
for (p = text; p < text + len; p++) {
|
||||||
|
|
||||||
if (octet > 255) {
|
|
||||||
return INADDR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
c = *p;
|
c = *p;
|
||||||
|
|
||||||
if (c >= '0' && c <= '9') {
|
if (c >= '0' && c <= '9') {
|
||||||
octet = octet * 10 + (c - '0');
|
octet = octet * 10 + (c - '0');
|
||||||
|
|
||||||
|
if (octet > 255) {
|
||||||
|
return INADDR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user