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.
This commit is contained in:
João Valverde 2021-10-15 17:09:22 +01:00
parent 6d4a463620
commit 06890ea379
1 changed files with 6 additions and 0 deletions

View File

@ -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