aboutsummaryrefslogtreecommitdiffstats
path: root/epan/proto.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2022-06-25 11:25:36 +0100
committerJoão Valverde <j@v6e.pt>2022-07-02 11:18:20 +0100
commitb10db887ce9c5a4430d468eeebc8d7e42c6c6eb8 (patch)
treedc2c17e45069047f4508b86c2020cd30a2aa44a9 /epan/proto.c
parent190404d66bdb2573ca224967e368288b78fe525d (diff)
dfilter: Remove unparsed syntax type and RHS literal bias
This removes unparsed name resolution during the semantic check because it feels like a hack to work around limitations in the language syntax, that should be solved at the lexical level instead. We were interpreting unparsed differently on the LHS and RHS. Now an unparsed value is always a field if it matches a registered field name (this matches the implementation in 3.6 and before). This requires tightening a bit the allowed filter names for protocols to avoid some common and potentially weird conflicting cases. Incidentally this extends set grammar to accept all entities. That is experimental and may be reverted in the future.
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/epan/proto.c b/epan/proto.c
index 397c649bc9..c45073c303 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -7425,12 +7425,38 @@ proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start,
static void
check_protocol_filter_name_or_fail(const char *filter_name)
{
+ /* Require at least two characters. */
+ if (filter_name[0] == '\0' || filter_name[1] == '\0') {
+ REPORT_DISSECTOR_BUG("Protocol filter name \"%s\" cannot have length less than two.", filter_name);
+ }
+
if (proto_check_field_name(filter_name) != '\0') {
REPORT_DISSECTOR_BUG("Protocol filter name \"%s\" has one or more invalid characters."
" Allowed are letters, digits, '-', '_' and non-repeating '.'."
" This might be caused by an inappropriate plugin or a development error.", filter_name);
}
+ /* Check that it doesn't match some very common numeric forms. */
+ if (filter_name[0] == '0' &&
+ (filter_name[1] == 'x' || filter_name[1] == 'X' ||
+ filter_name[1] == 'b' || filter_name[1] == 'B')) {
+ REPORT_DISSECTOR_BUG("Protocol filter name \"%s\" cannot start with \"%c%c\".",
+ filter_name, filter_name[0], filter_name[1]);
+ }
+
+ /* Check that it doesn't have all decimal digits. */
+ bool all_digits = true;
+ for (const char *s = filter_name; *s != '\0'; s++) {
+ if (!g_ascii_isdigit(*s)) {
+ all_digits = false;
+ break;
+ }
+ }
+ if (all_digits) {
+ REPORT_DISSECTOR_BUG("Protocol filter name \"%s\" cannot be composed of all decimal digits.",
+ filter_name);
+ }
+
/* Check for reserved keywords. */
if (g_hash_table_contains(proto_reserved_filter_names, filter_name)) {
REPORT_DISSECTOR_BUG("Protocol filter name \"%s\" is invalid because it is a reserved keyword."