forked from osmocom/wireshark
dfilter: Fix a crash using abs()
Passing a literal value to abs() on the LHS segfaults, because it is incorrectly assumed to be a valid field. We need to check if we actually have a field. While at it improve the diagnostic of literals.
This commit is contained in:
parent
9e84721c1a
commit
84f54d54e5
|
@ -408,17 +408,26 @@ ul_semcheck_absolute_value(dfwork_t *dfw, const char *func_name, ftenum_t lhs_ft
|
|||
if (stnode_type_id(st_node) == STTYPE_ARITHMETIC) {
|
||||
ftype = check_arithmetic_expr(dfw, st_node, lhs_ftype);
|
||||
}
|
||||
else if (stnode_type_id(st_node) == STTYPE_LITERAL && lhs_ftype != FT_NONE) {
|
||||
fv = dfilter_fvalue_from_literal(dfw, lhs_ftype, st_node, FALSE, NULL);
|
||||
stnode_replace(st_node, STTYPE_FVALUE, fv);
|
||||
ftype = fvalue_type_ftenum(fv);
|
||||
else if (stnode_type_id(st_node) == STTYPE_LITERAL) {
|
||||
if (lhs_ftype != FT_NONE) {
|
||||
/* Convert RHS literal to the same ftype as LHS. */
|
||||
fv = dfilter_fvalue_from_literal(dfw, lhs_ftype, st_node, FALSE, NULL);
|
||||
stnode_replace(st_node, STTYPE_FVALUE, fv);
|
||||
ftype = fvalue_type_ftenum(fv);
|
||||
}
|
||||
else {
|
||||
FAIL(dfw, st_node, "Need a field or field-like value on the LHS.");
|
||||
}
|
||||
}
|
||||
else if (stnode_type_id(st_node) == STTYPE_FUNCTION) {
|
||||
ftype = check_function(dfw, st_node, lhs_ftype);
|
||||
}
|
||||
else {
|
||||
else if (stnode_type_id(st_node) == STTYPE_FIELD) {
|
||||
ftype = sttype_field_ftenum(st_node);
|
||||
}
|
||||
else {
|
||||
ftype = FT_NONE;
|
||||
}
|
||||
|
||||
if (ftype == FT_NONE) {
|
||||
FAIL(dfw, st_node, "Type %s is not valid for %s",
|
||||
|
|
Loading…
Reference in New Issue