commit b9d8b1dbf364589f1c88f245ffda9fd269bd92cc
parent 12a7b483a0ed15a028d1509f172215bcd87e3e9c
Author: Daniel D’Aquino <daniel@daquino.me>
Date: Fri, 11 Jul 2025 16:47:40 -0700
Fix blocks_size calculation
Previously two addresses from different memory regions were being
subtracted, which will lead to the incorrect number. This commit
improves the calculation.
Changelog-None
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/nostrdb/src/content_parser.c b/nostrdb/src/content_parser.c
@@ -594,7 +594,8 @@ int ndb_parse_content(unsigned char *buf, int buf_size,
return 0;
}
- parser.blocks->blocks_size = parser.buffer.p - blocks_start;
+ parser.blocks->blocks_size = parser.buffer.p - (parser.buffer.start + sizeof(struct ndb_blocks));
+ assert(parser.blocks->blocks_size < ((2<<18) + 1));
//
// pad to 8-byte alignment
@@ -606,4 +607,3 @@ int ndb_parse_content(unsigned char *buf, int buf_size,
return 1;
}
-