Skip to content

Commit

Permalink
dict BUGFIX check whole compared string
Browse files Browse the repository at this point in the history
Fixes #2108
  • Loading branch information
michalvasko committed Sep 29, 2023
1 parent 216c66f commit de17be1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@
static ly_bool
lydict_val_eq(void *val1_p, void *val2_p, ly_bool UNUSED(mod), void *cb_data)
{
const char *str1, *str2;
size_t *len1;

LY_CHECK_ARG_RET(NULL, val1_p, val2_p, cb_data, 0);

const char *str1 = ((struct ly_dict_rec *)val1_p)->value;
const char *str2 = ((struct ly_dict_rec *)val2_p)->value;
str1 = ((struct ly_dict_rec *)val1_p)->value;
str2 = ((struct ly_dict_rec *)val2_p)->value;
len1 = cb_data;

LY_CHECK_ERR_RET(!str1, LOGARG(NULL, val1_p), 0);
LY_CHECK_ERR_RET(!str2, LOGARG(NULL, val2_p), 0);

if (strncmp(str1, str2, *(size_t *)cb_data) == 0) {
if (!strncmp(str1, str2, *len1) && !str2[*len1]) {
return 1;
}

Expand Down

0 comments on commit de17be1

Please sign in to comment.