From 6183ca9ea8b76e3da42d6d866936e3d55702ee9d Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Fri, 17 Feb 2017 17:01:27 +0300 Subject: [PATCH] Fixed ngx_parse_size() / ngx_parse_offset() with 0-length strings. --- src/core/ngx_parse.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/ngx_parse.c b/src/core/ngx_parse.c index 7b60c5fb6..d35e60fac 100644 --- a/src/core/ngx_parse.c +++ b/src/core/ngx_parse.c @@ -17,6 +17,11 @@ ngx_parse_size(ngx_str_t *line) ssize_t size, scale, max; len = line->len; + + if (len == 0) { + return NGX_ERROR; + } + unit = line->data[len - 1]; switch (unit) { @@ -58,6 +63,11 @@ ngx_parse_offset(ngx_str_t *line) size_t len; len = line->len; + + if (len == 0) { + return NGX_ERROR; + } + unit = line->data[len - 1]; switch (unit) {