From 06890ea379ee833fc15cc08023a153bb89741651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Fri, 15 Oct 2021 17:09:22 +0100 Subject: dfilter: Forbid protocol filter names beginning with '-' Reducing the namespace for protocol names makes the display filter grammar simpler and less ambiguous and error prone. We can't easily impose stricter restrictions without breaking backward compatibility but names starting with '-' are a pathological case because of negative numbers and byte slices and in the unlikely event that any such names exist they should be fixed. --- epan/proto.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/epan/proto.c b/epan/proto.c index 8b906dd44c..0b7e66b9a0 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -7385,6 +7385,12 @@ check_valid_filter_name_or_fail(const char *filter_name) ws_error("Protocol filter name \"%s\" is invalid because it is a reserved keyword." " This might be caused by an inappropriate plugin or a development error.", filter_name); } + + /* First character cannot be '-'. */ + if (filter_name[0] == '-') { + ws_error("Protocol filter name \"%s\" cannot begin with '-'." + " This might be caused by an inappropriate plugin or a development error.", filter_name); + } } int -- cgit v1.2.3