From: OwenSanzas Date: Thu, 15 Jan 2026 00:15:35 +0000 (+0000) Subject: Shell: fixed fuzzer harness to add NULL termination. X-Git-Tag: 0.9.6~30 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=f1fa26fba0d0a96e8c6c033eb02f7329db7a74cf;p=njs.git Shell: fixed fuzzer harness to add NULL termination. Guided-by: Dmitry Volyntsev Signed-off-by: Ze Sheng Co-Authored-By: Claude Code --- diff --git a/external/njs_shell.c b/external/njs_shell.c index d0f9e25f..63f502ab 100644 --- a/external/njs_shell.c +++ b/external/njs_shell.c @@ -847,20 +847,33 @@ njs_options_free(njs_opts_t *opts) int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + u_char *buf; njs_opts_t opts; if (size == 0) { return 0; } + buf = malloc(size + 1); + if (buf == NULL) { + return 0; + } + + memcpy(buf, data, size); + buf[size] = '\0'; + njs_memzero(&opts, sizeof(njs_opts_t)); opts.file = (char *) "fuzzer"; - opts.command.start = (u_char *) data; + opts.command.start = buf; opts.command.length = size; opts.suppress_stdout = 1; - return njs_main(&opts); + (void) njs_main(&opts); + + free(buf); + + return 0; } #endif