From 01f20c84f97faed452ebe7fae75b460161c34bdb Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 13 May 2023 20:38:56 +0200 Subject: [PATCH] Added verification of token buffer length when using TOKEN_ATTR_FIXED_LENGTH --- docs/changes.txt | 1 + src/shared.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 7196734d3..3f034fc56 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -58,6 +58,7 @@ - Fixed bug in 29600 module OPTS_TYPE setting - Fixed bug in grep out-of-memory workaround on Unit Test - Fixed bug in input_tokenizer when TOKEN_ATTR_FIXED_LENGTH is used and refactor modules +- Added verification of token buffer length when using TOKEN_ATTR_FIXED_LENGTH - Fixed build failed for 4410 with vector width > 1 - Fixed build failed for 18400 with Apple Metal - Fixed build failed for 18600 with Apple Metal diff --git a/src/shared.c b/src/shared.c index a4b835aee..ddfc35848 100644 --- a/src/shared.c +++ b/src/shared.c @@ -1190,6 +1190,11 @@ int input_tokenizer (const u8 *input_buf, const int input_len, hc_token_t *token const int len = next_pos - token->buf[token_idx]; + if (token->attr[token_idx] & TOKEN_ATTR_FIXED_LENGTH) + { + if (len != token->len[token_idx]) return (PARSER_TOKEN_LENGTH); + } + token->len[token_idx] = len; token->buf[token_idx + 1] = next_pos + 1; // +1 = separator