Skip to content

Commit e784f9f

Browse files
config_format: fix possible heap overflow (#7768)
The return value of `strchr` is not checked for failure. If it's failure then `tmp` will be `0` in the `(tmp-p)` calculation, causing `xlen` to be `p`. `xlen` is later used for copying memory by way of `memcpy` in string creation using `flb_sds_create_len`. This fixes it. Signed-off-by: David Korczynski <[email protected]>
1 parent 5686334 commit e784f9f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/config_format/flb_config_format.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ struct flb_kv *flb_cf_meta_property_add(struct flb_cf *cf, char *meta, int len)
420420

421421
p = meta;
422422
tmp = strchr(p, ' ');
423+
if (tmp == NULL) {
424+
return NULL;
425+
}
423426
xlen = (tmp - p);
424427

425428
/* create k/v pair */

0 commit comments

Comments
 (0)