mirror of
https://github.com/nginx/nginx.git
synced 2026-11-20 15:13:10 +00:00
The regex pattern was referenced from the temporary pool used for map block parsing, which is destroyed once the block is parsed. The pattern is later used for logging if regex matching fails, e.g., due to PCRE2 match limit, JIT stack limit, or invalid UTF-8 with (*UTF), resulting in released memory being logged. The fix is to copy the pattern into the configuration pool.
This commit is contained in:
parent
62f94cf696
commit
d17f1d249d
2 changed files with 16 additions and 2 deletions
|
|
@ -547,7 +547,14 @@ found:
|
|||
rc.options = NGX_REGEX_CASELESS;
|
||||
}
|
||||
|
||||
rc.pattern = value[0];
|
||||
rc.pattern.len = value[0].len;
|
||||
rc.pattern.data = ngx_pnalloc(ctx->keys.pool, value[0].len + 1);
|
||||
if (rc.pattern.data == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ngx_memcpy(rc.pattern.data, value[0].data, value[0].len + 1);
|
||||
|
||||
rc.err.len = NGX_MAX_CONF_ERRSTR;
|
||||
rc.err.data = errstr;
|
||||
|
||||
|
|
|
|||
|
|
@ -546,7 +546,14 @@ found:
|
|||
rc.options = NGX_REGEX_CASELESS;
|
||||
}
|
||||
|
||||
rc.pattern = value[0];
|
||||
rc.pattern.len = value[0].len;
|
||||
rc.pattern.data = ngx_pnalloc(ctx->keys.pool, value[0].len + 1);
|
||||
if (rc.pattern.data == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ngx_memcpy(rc.pattern.data, value[0].data, value[0].len + 1);
|
||||
|
||||
rc.err.len = NGX_MAX_CONF_ERRSTR;
|
||||
rc.err.data = errstr;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue