From 89ad9ea30946dacb2fcf088a97f5a40d3b408d2c Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Tue, 28 Apr 2015 18:55:03 +0300 Subject: [PATCH] Fixed overflow detection in ngx_inet_addr(). Overflow detection of the last octet might not work. Reported by Sergey Polovko. --- src/core/ngx_inet.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c index 2c84daf6e..96a04fded 100644 --- a/src/core/ngx_inet.c +++ b/src/core/ngx_inet.c @@ -26,15 +26,15 @@ ngx_inet_addr(u_char *text, size_t len) n = 0; for (p = text; p < text + len; p++) { - - if (octet > 255) { - return INADDR_NONE; - } - c = *p; if (c >= '0' && c <= '9') { octet = octet * 10 + (c - '0'); + + if (octet > 255) { + return INADDR_NONE; + } + continue; }