From 12a7b483a0ed15a028d1509f172215bcd87e3e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Fri, 11 Jul 2025 16:44:55 -0700 Subject: [PATCH] Fix incorrect buffer size argument in block parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changelog-None Signed-off-by: Daniel D’Aquino --- nostrdb/src/nostrdb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nostrdb/src/nostrdb.c b/nostrdb/src/nostrdb.c index f27ba7f8..600eda9f 100644 --- a/nostrdb/src/nostrdb.c +++ b/nostrdb/src/nostrdb.c @@ -7095,12 +7095,14 @@ static struct ndb_blocks *ndb_note_to_blocks(struct ndb_note *note) // something weird is going on if (content_len >= INT32_MAX) return NULL; + + uint32_t buf_size = 2<<18; - buffer = malloc(2<<18); // Not carefully calculated, but ok because we will not need this once we switch to the local relay model + buffer = malloc(buf_size); // Not carefully calculated, but ok because we will not need this once we switch to the local relay model if (!buffer) return NULL; - if (!ndb_parse_content(buffer, content_len, content, content_len, &blocks)) { + if (!ndb_parse_content(buffer, buf_size, content, content_len, &blocks)) { free(buffer); return NULL; }