[nginx] Fixed excessive memory usage while parsing configuration.

Valentin Bartenev vbart at nginx.com
Mon Jun 1 18:10:11 UTC 2015


details:   http://hg.nginx.org/nginx/rev/4e71788460fa
branches:  
changeset: 6163:4e71788460fa
user:      Valentin Bartenev <vbart at nginx.com>
date:      Mon Jun 01 21:08:56 2015 +0300
description:
Fixed excessive memory usage while parsing configuration.

The b->pos points to the next symbol here.

Reported by ilexshen.

diffstat:

 src/core/ngx_conf_file.c |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r ab78c12412ce -r 4e71788460fa src/core/ngx_conf_file.c
--- a/src/core/ngx_conf_file.c	Mon Jun 01 16:58:07 2015 +0300
+++ b/src/core/ngx_conf_file.c	Mon Jun 01 21:08:56 2015 +0300
@@ -680,7 +680,7 @@ ngx_conf_read_token(ngx_conf_t *cf)
                     return NGX_ERROR;
                 }
 
-                word->data = ngx_pnalloc(cf->pool, b->pos - start + 1);
+                word->data = ngx_pnalloc(cf->pool, b->pos - 1 - start + 1);
                 if (word->data == NULL) {
                     return NGX_ERROR;
                 }



More information about the nginx-devel mailing list