Skip to content

Commit

Permalink
in_exec_wasi: fix possible NULL deref
Browse files Browse the repository at this point in the history
`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 <[email protected]>
  • Loading branch information
DavidKorczynski authored and nokute78 committed Jul 7, 2023
1 parent fb7d4c8 commit c58fc4f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/in_exec_wasi/in_exec_wasi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c58fc4f

Please sign in to comment.