diff options
author | Vladimir Homutov <vl@nginx.com> | 2016-07-06 14:33:40 +0300 |
---|---|---|
committer | Vladimir Homutov <vl@nginx.com> | 2016-07-06 14:33:40 +0300 |
commit | 161fcf4bddca789b15dcf22b1e1d80cdabc24114 (patch) | |
tree | e401444fe5692dd1d84f423f994ee2bf7bc70b32 /src/http/ngx_http_script.c | |
parent | 74305af6727afc0c737a8e993d5cd9183c5c71d2 (diff) | |
download | nginx-161fcf4bddca789b15dcf22b1e1d80cdabc24114.tar.gz nginx-161fcf4bddca789b15dcf22b1e1d80cdabc24114.zip |
Fixed regex captures handling without PCRE.
If PCRE is disabled, captures were treated as normal variables in
ngx_http_script_compile(), while code calculating flushes array length in
ngx_http_compile_complex_value() did not account captures as variables.
This could lead to write outside of the array boundary when setting
last element to -1.
Found with AddressSanitizer.
Diffstat (limited to 'src/http/ngx_http_script.c')
-rw-r--r-- | src/http/ngx_http_script.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c index bff95250c..c2b165801 100644 --- a/src/http/ngx_http_script.c +++ b/src/http/ngx_http_script.c @@ -350,11 +350,9 @@ ngx_http_script_compile(ngx_http_script_compile_t *sc) goto invalid_variable; } -#if (NGX_PCRE) - { - ngx_uint_t n; - if (sc->source->data[i] >= '1' && sc->source->data[i] <= '9') { +#if (NGX_PCRE) + ngx_uint_t n; n = sc->source->data[i] - '0'; @@ -371,9 +369,13 @@ ngx_http_script_compile(ngx_http_script_compile_t *sc) i++; continue; - } - } +#else + ngx_conf_log_error(NGX_LOG_EMERG, sc->cf, 0, + "using variable \"$%c\" requires " + "PCRE library", sc->source->data[i]); + return NGX_ERROR; #endif + } if (sc->source->data[i] == '{') { bracket = 1; |