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>
This commit is contained in:
Daniel D’Aquino
2025-07-11 16:47:40 -07:00
parent 12a7b483a0
commit b9d8b1dbf3

View File

@@ -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;
}