aboutsummaryrefslogtreecommitdiff
path: root/nginx/ngx_js.c
diff options
context:
space:
mode:
authorDmitry Volyntsev <xeioex@nginx.com>2025-02-12 19:11:08 -0800
committerDmitry Volyntsev <xeioexception@gmail.com>2025-02-18 16:30:00 -0800
commitb6d108c812c07b11d4c3f65a48a5898139ac1ae4 (patch)
tree754d96e34dd0f319ff1489b4c3af96543114487b /nginx/ngx_js.c
parent0b6eca0a123000297d4e18d46770bad7416d5056 (diff)
downloadnjs-b6d108c812c07b11d4c3f65a48a5898139ac1ae4.tar.gz
njs-b6d108c812c07b11d4c3f65a48a5898139ac1ae4.zip
QuickJS: fixed non-NULL terminated strings formatting in exceptions.
When "%*s" is specified, the first integer is interpreted as width. Width specifies *minimum* number of characters to output. The next string is expected to be NULL-terminated. When "%.*s" is specified, the first integer is interpreted as precision. Precision specifies *maximum* number of characters to output.
Diffstat (limited to 'nginx/ngx_js.c')
-rw-r--r--nginx/ngx_js.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/nginx/ngx_js.c b/nginx/ngx_js.c
index 5c2a44cb..7f7b7362 100644
--- a/nginx/ngx_js.c
+++ b/nginx/ngx_js.c
@@ -1988,7 +1988,7 @@ ngx_qjs_module_loader(JSContext *cx, const char *module_name, void *opaque)
(void) close(info.fd);
if (ret != NJS_OK) {
- JS_ThrowInternalError(cx, "while reading \"%*s\" module",
+ JS_ThrowInternalError(cx, "while reading \"%.*s\" module",
(int) info.file.length, info.file.start);
return NULL;
}
@@ -2057,7 +2057,7 @@ ngx_qjs_unhandled_rejection(ngx_js_ctx_t *ctx)
return -1;
}
- JS_ThrowTypeError(cx, "unhandled promise rejection: %*s", (int) len, str);
+ JS_ThrowTypeError(cx, "unhandled promise rejection: %.*s", (int) len, str);
JS_FreeCString(cx, str);
for (i = 0; i < ctx->rejected_promises->items; i++) {