-
Incident report
-
Resolution: Fixed
-
Major
-
2.2.13rc1, 3.0.3rc1, 3.2.0alpha1
-
Sprint 36, Sprint 37, Sprint 38, Sprint 39, Sprint 40, Sprint 41, Sprint 42, Sprint 43, Sprint 44
-
2
Zabbix has multiple functions to check whether string contains a float and several functions to convert string to double. Results of it are really weird.
Calculated item with expression count(float.trapper,#10,.) will count zeros because is_double_suffix() treats "." as a valid number and str2double() than converts it using atof() which cannot return errors.
Calculated item with expression count(float.trapper,#10,+1) will fail to count anything. In 3.0 it will always return 0, in current trunk it will return a visible error. That's because is_double_suffix() rejects numbers starting with plus.
is_double_suffix() is used in trigger function count() and for user macro resolving in trigger and calculated item expressions. is_double correctly says that "." is not a number and numbers starting with plus sign are OK.
The consequences of performing
zbx_rtrim(c, " \""); zbx_ltrim(c, " \"+");
in set_result_type() and get_result_dbl_value() are that one can do so:
$ src/zabbix_sender/zabbix_sender -z localhost -p 30051 -s Testing -k float.trapper -o ' "+ "+ + + -3.0 " " ' info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000066" sent: 1; skipped: 0; total: 1
and Zabbix will store -3.0 in database.
This affects all checks using text to double conversion at some point: user parameters, external scripts, etc. with type Numeric (float).
There should be one function to validate and optionally convert string containing a decimal number (possibly surrounded by whitespace, possibly quoted, possibly with plus or minus, possibly with exponent or suffixes).