diff options
author | João Valverde <j@v6e.pt> | 2022-04-06 17:29:56 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2022-04-06 18:09:12 +0100 |
commit | 8108e67de773e2798b480df946e3b285d4303846 (patch) | |
tree | adbc594120885f1e8f68aae071c52a01f0886aba /epan/dfilter | |
parent | 85be944ebe1af117f0f1698f8e99f763de83e824 (diff) |
dfilter: Fix memory leak with leading colon
When retrying fvalue_from_literal() we were leaking the error
message string.
Refactor the code to avoid the retry. This assumes the only
valid use of a leading ':' with a literal is for an IPv6 address.
Bytes with leading ':' are supported but the colon is skipped,
so the parser doesn't see it.
Fixes df0fc8b517b38f261e9d39515b57eed32bbd0347.
Diffstat (limited to 'epan/dfilter')
-rw-r--r-- | epan/dfilter/scanner.l | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/epan/dfilter/scanner.l b/epan/dfilter/scanner.l index c8838a7219..cd63e08e7e 100644 --- a/epan/dfilter/scanner.l +++ b/epan/dfilter/scanner.l @@ -378,8 +378,12 @@ v6-cidr-prefix \/[[:digit:]]{1,3} return set_lval_str(TOKEN_UNPARSED, yytext); } -[[:xdigit:]]+:[[:xdigit:]:]* { +:?[[:xdigit:]]+:[[:xdigit:]:]* { /* Bytes. */ + if (yytext[0] == ':') { + /* Skip leading colon. */ + return set_lval_str(TOKEN_LITERAL, yytext + 1); + } return set_lval_str(TOKEN_UNPARSED, yytext); } @@ -392,8 +396,10 @@ v6-cidr-prefix \/[[:digit:]]{1,3} /* Identifier or literal or unparsed. */ if (yytext[0] == '.') return set_lval_str(TOKEN_IDENTIFIER, yytext); - if (yytext[0] == ':') - return set_lval_str(TOKEN_LITERAL, yytext); + if (yytext[0] == ':') { + /* Skip leading colon. */ + return set_lval_str(TOKEN_LITERAL, yytext + 1); + } return set_lval_str(TOKEN_UNPARSED, yytext); } |