damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 969a2b656e486d6f957ba5e20f2d8ac843517df0
parent d8e7b4707e7eeac077ee273df0d486f840fe5d0a
Author: Daniel D’Aquino <daniel@daquino.me>
Date:   Wed,  4 Jun 2025 20:47:57 -0700

nostrdb: Fix heap buffer overflow

The Address Sanitizer detected a heap buffer overflow during a memcpy operation
in nostrdb.c associated with note parsing.

It was found that not enough memory was being allocated to the buffer to
support all the content parsing.

Allocation size was increased to support the memory needed for the
parsing operations. However, the new number was not carefully calculated
as we will not run into this code path once we switch to the local relay
model.

Changelog-Fixed: Fixed memory error in nostrdb
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>

Diffstat:
Mnostrdb/src/nostrdb.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nostrdb/src/nostrdb.c b/nostrdb/src/nostrdb.c @@ -7089,7 +7089,7 @@ static struct ndb_blocks *ndb_note_to_blocks(struct ndb_note *note) if (content_len >= INT32_MAX) return NULL; - unsigned char *buffer = malloc(content_len); + unsigned char *buffer = malloc(2<<18); // Not carefully calculated, but ok because we will not need this once we switch to the local relay model if (!buffer) return NULL;