Skip to content

Commit

Permalink
consider length of string keys (#308)
Browse files Browse the repository at this point in the history
Prevent str_set comparison from accepting prefix as false positive
  • Loading branch information
mdrossmiller authored Oct 29, 2024
1 parent 4dfe2dc commit b5dbdd8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion external/hash/str_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ DEFINE_HASH_TABLE(str_set)
*/
static inline int ht_match(const void *key, size_t len, str_set_item_t item)
{
return strncmp(key, item, len) == 0;
return strncmp(key, item, len) == 0 && item[len] == '\0';
}

static inline const void *ht_key(str_set_item_t item)
Expand Down

0 comments on commit b5dbdd8

Please sign in to comment.