nostrdb: content_parser: fix blocks_size
we are crossing cursors Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
Daniel D’Aquino
parent
6001063754
commit
6c53bc75f2
@@ -522,7 +522,7 @@ int ndb_parse_content(unsigned char *buf, int buf_size,
|
|||||||
struct ndb_content_parser parser;
|
struct ndb_content_parser parser;
|
||||||
struct ndb_block block;
|
struct ndb_block block;
|
||||||
|
|
||||||
unsigned char *start, *pre_mention, *blocks_start;
|
unsigned char *start, *pre_mention;
|
||||||
|
|
||||||
make_cursor(buf, buf + buf_size, &parser.buffer);
|
make_cursor(buf, buf + buf_size, &parser.buffer);
|
||||||
|
|
||||||
@@ -539,7 +539,7 @@ int ndb_parse_content(unsigned char *buf, int buf_size,
|
|||||||
parser.blocks->flags = 0;
|
parser.blocks->flags = 0;
|
||||||
parser.blocks->version = 1;
|
parser.blocks->version = 1;
|
||||||
|
|
||||||
blocks_start = start = parser.content.p;
|
start = parser.content.p;
|
||||||
while (parser.content.p < parser.content.end) {
|
while (parser.content.p < parser.content.end) {
|
||||||
cp = peek_char(&parser.content, -1);
|
cp = peek_char(&parser.content, -1);
|
||||||
c = peek_char(&parser.content, 0);
|
c = peek_char(&parser.content, 0);
|
||||||
@@ -577,7 +577,7 @@ int ndb_parse_content(unsigned char *buf, int buf_size,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.blocks->blocks_size = parser.buffer.p - blocks_start;
|
parser.blocks->blocks_size = parser.buffer.p - parser.buffer.start;
|
||||||
|
|
||||||
//
|
//
|
||||||
// pad to 8-byte alignment
|
// pad to 8-byte alignment
|
||||||
|
|||||||
Reference in New Issue
Block a user