Skip to content

Commit

Permalink
kvlist: on insert check strings are valid
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Feb 25, 2024
1 parent ded2f85 commit 6cb916f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/cfl_kvlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,17 @@ struct cfl_variant *cfl_kvlist_fetch_s(struct cfl_kvlist *list, char *key, size_
int cfl_kvlist_insert_string(struct cfl_kvlist *list,
char *key, char *value)
{
return cfl_kvlist_insert_string_s(list, key, strlen(key), value, strlen(value));
int key_len;
int val_len;

if (!key || !value) {
return -1;
}

key_len = strlen(key);
val_len = strlen(value);

return cfl_kvlist_insert_string_s(list, key, key_len, value, val_len);
}

int cfl_kvlist_insert_bytes(struct cfl_kvlist *list,
Expand Down

0 comments on commit 6cb916f

Please sign in to comment.