line_offset of 2^32 bytes should be enough. This requires the removal of the last_line field (in a previous patch) to shrink struct expr to 112 bytes. Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- include/nftables.h | 3 +-- src/scanner.l | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/nftables.h b/include/nftables.h index a6f0e6128887..2e0d91486a29 100644 --- a/include/nftables.h +++ b/include/nftables.h @@ -158,8 +158,7 @@ struct location { const struct input_descriptor *indesc; union { struct { - off_t line_offset; - + unsigned int line_offset; unsigned int first_line; unsigned int first_column; unsigned int last_column; diff --git a/src/scanner.l b/src/scanner.l index 4a340b00fdc6..9ccbc22d2120 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -88,8 +88,15 @@ static void update_pos(struct parser_state *state, struct location *loc, static void update_offset(struct parser_state *state, struct location *loc, unsigned int len) { + uint32_t line_offset; + state->indesc->token_offset += len; - loc->line_offset = state->indesc->line_offset; + if (state->indesc->line_offset > UINT32_MAX) + line_offset = UINT32_MAX; + else + line_offset = state->indesc->line_offset; + + loc->line_offset = line_offset; } static void reset_pos(struct parser_state *state, struct location *loc) -- 2.30.2