Wrong order of operations in substitute_simple_macros()

XMLWordPrintable

      In substitute_simple_macros() macro value is checked for being numeric before macro function is applied:

      		if (1 == require_numeric && NULL != replace_to)
      		{
      			if (SUCCEED == (res = is_double_suffix(replace_to, ZBX_FLAG_DOUBLE_SUFFIX)))
      				wrap_negative_double_suffix(&replace_to, NULL);
      			else if (NULL != error)
      				zbx_snprintf(error, maxerrlen, "Macro '%s' value is not numeric", m);
      		}
      
      		if (ZBX_TOKEN_FUNC_MACRO == token.type && NULL != replace_to)
      		{
      			if (0 != func_macro)
      			{
      				ret = zbx_calculate_macro_function(*data + token.data.func_macro.func.l,
      						token.data.func_macro.func.r - token.data.func_macro.func.l + 1,
      						&replace_to);
      			}
      			else
      			{
      				/* ignore functions with macros not supporting them */
      				zbx_free(replace_to);
      			}
      		}
      

      There are no observable effects of this bug because macros for which macro functions are supported can't be used in expressions and formulas where numeric value is mandatory. But let's not wait until there are any.

            Assignee:
            Unassigned
            Reporter:
            Glebs Ivanovskis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: