From c58fc4fbabe525ade1445d12b9d4a835151c6cd5 Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Fri, 30 Jun 2023 03:34:24 -0700 Subject: [PATCH] in_exec_wasi: fix possible NULL deref `tmpfile()` can return NULL and this is not checked for at the moment. If indeed it returns NULL then the call on line 70 `fileno(stdoutp)` will cause a NULL dereference. Signed-off-by: David Korczynski --- plugins/in_exec_wasi/in_exec_wasi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/in_exec_wasi/in_exec_wasi.c b/plugins/in_exec_wasi/in_exec_wasi.c index 2515dd8584f..071aadee9d9 100644 --- a/plugins/in_exec_wasi/in_exec_wasi.c +++ b/plugins/in_exec_wasi/in_exec_wasi.c @@ -59,6 +59,11 @@ static int in_exec_wasi_collect(struct flb_input_instance *ins, size_t out_size = 0; struct flb_time out_time; + /* Validate the temporary file was created */ + if (stdoutp == NULL) { + return -1; + } + if (ctx->oneshot == FLB_TRUE) { ret = flb_pipe_r(ctx->ch_manager[0], &val, sizeof(val)); if (ret == -1) {