From 969a2b656e486d6f957ba5e20f2d8ac843517df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Wed, 4 Jun 2025 20:47:57 -0700 Subject: [PATCH] nostrdb: Fix heap buffer overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- 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 ce6e1296..a2464ac6 100644 --- 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;