From 60010637549d8a1754e540523bdfb6e388b47e99 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 24 Aug 2024 16:44:52 +0930 Subject: [PATCH] nostrdb: nostrdb: fix ndb_builder_find_str. This will find strings which match the beginning of other strings, which seems wrong. Signed-off-by: Rusty Russell Signed-off-by: William Casarin --- nostrdb/src/nostrdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nostrdb/src/nostrdb.c b/nostrdb/src/nostrdb.c index 3561b7d3..c569be11 100644 --- a/nostrdb/src/nostrdb.c +++ b/nostrdb/src/nostrdb.c @@ -5071,7 +5071,7 @@ static inline int ndb_builder_find_str(struct ndb_builder *builder, uint32_t index = ((uint32_t*)builder->str_indices.start)[i]; const char *some_str = (const char*)builder->strings.start + index; - if (!memcmp(some_str, str, len)) { + if (!memcmp(some_str, str, len) && some_str[len] == '\0') { // found an existing matching str, use that index *pstr = ndb_offset_str(index); return 1;