Skip to content

Commit

Permalink
config_format: fix possible heap overflow (#7768)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
DavidKorczynski authored Aug 8, 2023
1 parent 5686334 commit e784f9f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/config_format/flb_config_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ struct flb_kv *flb_cf_meta_property_add(struct flb_cf *cf, char *meta, int len)

p = meta;
tmp = strchr(p, ' ');
if (tmp == NULL) {
return NULL;
}
xlen = (tmp - p);

/* create k/v pair */
Expand Down

0 comments on commit e784f9f

Please sign in to comment.