dfilter: Fix crash with min/max literal argument

Filter: max(1,_ws.ftypes.int8) == 1
     ** (dftest:64938) 01:43:25.950180 [DFilter ERROR] epan/dfilter/sttype-field.c:117 -- sttype_field_ftenum(): Magic num is 0x5cf30031, but should be 0xfc2002cf
This commit is contained in:
João Valverde 2022-12-26 20:37:55 +00:00
parent 6c8cdebe87
commit 6399f724d9
2 changed files with 12 additions and 8 deletions

View File

@ -352,12 +352,11 @@ ul_semcheck_compare(dfwork_t *dfw, const char *func_name, ftenum_t lhs_ftype,
else if (stnode_type_id(arg) == STTYPE_FUNCTION) {
ftype = check_function(dfw, arg, lhs_ftype);
}
else {
else if (stnode_type_id(arg) == STTYPE_FIELD || stnode_type_id(arg) == STTYPE_REFERENCE) {
ftype = sttype_field_ftenum(arg);
}
if (ftype == FT_NONE) {
FAIL(dfw, arg, "Argument '%s' (FT_NONE) is not valid for %s()",
else {
FAIL(dfw, arg, "Argument '%s' is not valid for %s()",
stnode_todisplay(arg), func_name);
}
@ -375,14 +374,14 @@ ul_semcheck_compare(dfwork_t *dfw, const char *func_name, ftenum_t lhs_ftype,
else if (stnode_type_id(arg) == STTYPE_FUNCTION) {
ft_arg = check_function(dfw, arg, ftype);
}
else {
else if (stnode_type_id(arg) == STTYPE_FIELD || stnode_type_id(arg) == STTYPE_REFERENCE) {
ft_arg = sttype_field_ftenum(arg);
}
if (ft_arg == FT_NONE) {
FAIL(dfw, arg, "Argument '%s' (FT_NONE) is not valid for %s()",
else {
FAIL(dfw, arg, "Argument '%s' is not valid for %s()",
stnode_todisplay(arg), func_name);
}
if (ftype == FT_NONE) {
ftype = ft_arg;
}

View File

@ -66,6 +66,11 @@ class case_dfunction_maxmin(unittest.TestCase):
dfilter = 'max(udp.srcport, udp.dstport) < 5060'
checkDFilterCount(dfilter, 1)
def test_max_4(self, checkDFilterFail):
error = 'Argument \'1\' is not valid for max()'
dfilter = 'max(1,_ws.ftypes.int8) == 1'
checkDFilterFail(dfilter, error)
@fixtures.uses_fixtures
class case_dfunction_abs(unittest.TestCase):
trace_file = "dhcp.pcapng"