[nginx] Fixed ngx_parse_size() / ngx_parse_offset() with 0-length strings.

Maxim Dounin mdounin at mdounin.ru
Fri Feb 17 15:27:25 UTC 2017


details:   http://hg.nginx.org/nginx/rev/87cf6ddb41c2
branches:  
changeset: 6917:87cf6ddb41c2
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Fri Feb 17 17:01:27 2017 +0300
description:
Fixed ngx_parse_size() / ngx_parse_offset() with 0-length strings.

diffstat:

 src/core/ngx_parse.c |  10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diffs (27 lines):

diff --git a/src/core/ngx_parse.c b/src/core/ngx_parse.c
--- 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) {


More information about the nginx-devel mailing list