Skip to content

Commit 50e62c9

Browse files
committed
filter_kubernetes: tests: Fix possible buffer overrun
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 9cf4c9f commit 50e62c9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/runtime/filter_kubernetes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static int file_to_buf(const char *path, char **out_buf, size_t *out_size)
8686
return -1;
8787
}
8888

89-
buf = flb_malloc(st.st_size);
89+
buf = flb_malloc(st.st_size + 1);
9090
if (!buf) {
9191
flb_errno();
9292
fclose(fp);
@@ -100,6 +100,7 @@ static int file_to_buf(const char *path, char **out_buf, size_t *out_size)
100100
fclose(fp);
101101
return -1;
102102
}
103+
buf[st.st_size] = '\0';
103104

104105
fclose(fp);
105106
*out_buf = buf;

0 commit comments

Comments
 (0)