diff --git a/epan/dfilter/dfunctions.c b/epan/dfilter/dfunctions.c index ba8de42705..5c8b122878 100644 --- a/epan/dfilter/dfunctions.c +++ b/epan/dfilter/dfunctions.c @@ -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; } diff --git a/test/suite_dfilter/group_function.py b/test/suite_dfilter/group_function.py index 460599a6c9..9d80082b3f 100644 --- a/test/suite_dfilter/group_function.py +++ b/test/suite_dfilter/group_function.py @@ -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"