Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-10784

Validation of double/Numeric(float) values is inconsistent and sometimes really wrong

XMLWordPrintable

    • 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).

            MVekslers Michael Veksler
            glebs.ivanovskis Glebs Ivanovskis (Inactive)
            Team A
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: