diff options
author | Dmitry Volyntsev <xeioex@nginx.com> | 2025-07-07 22:40:45 -0700 |
---|---|---|
committer | Dmitry Volyntsev <xeioexception@gmail.com> | 2025-07-08 15:25:58 -0700 |
commit | a4addc9b3145313f74de31b592e3b36714987ea0 (patch) | |
tree | 46bdb66220090b6f0212386514da8ee33ad0ec02 /nginx/ngx_http_js_module.c | |
parent | ecc237b079a699537351ddc3dd1ade2f96918451 (diff) | |
download | njs-a4addc9b3145313f74de31b592e3b36714987ea0.tar.gz njs-a4addc9b3145313f74de31b592e3b36714987ea0.zip |
Fixed NULL pointer dereference when processing If-* headers.
Previously, when processing requests with If-Match and
If-Unmodified-Since headers worker process crashed.
For example with the following code:
try { r.return(200) }
catch (e) { r.internalRedirect() }
The fix is to disable not_modified filter as it was done in
nginx perl module nginx/nginx@d9887ee2.
Diffstat (limited to 'nginx/ngx_http_js_module.c')
-rw-r--r-- | nginx/ngx_http_js_module.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index 1e0a927f..45ddf17e 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -2455,6 +2455,8 @@ ngx_http_js_ext_send_header(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, return NJS_ERROR; } + r->disable_not_modified = 1; + if (ngx_http_send_header(r) == NGX_ERROR) { return NJS_ERROR; } @@ -2738,6 +2740,8 @@ ngx_http_js_ext_return(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, cv.value.data = text.start; cv.value.len = text.length; + r->disable_not_modified = 1; + ctx->status = ngx_http_send_response(r, status, NULL, &cv); if (ctx->status == NGX_ERROR) { @@ -5445,6 +5449,8 @@ ngx_http_qjs_ext_return(JSContext *cx, JSValueConst this_val, cv.value.data = body.data; cv.value.len = body.len; + r->disable_not_modified = 1; + ctx->status = ngx_http_send_response(r, status, NULL, &cv); if (ctx->status == NGX_ERROR) { @@ -5670,6 +5676,8 @@ ngx_http_qjs_ext_send_header(JSContext *cx, JSValueConst this_val, return JS_ThrowInternalError(cx, "failed to set content type"); } + r->disable_not_modified = 1; + if (ngx_http_send_header(r) == NGX_ERROR) { return JS_ThrowInternalError(cx, "failed to send header"); } |