Rainer Gerhards 8b888e4a64 rainerscript: fix array and numeric comparisons on JSON vars
Why:
Array comparisons against JSON/local variables ($.var != [...])
incorrectly collapsed arrays to their first elements, and raw
numeric comparisons incorrectly accessed raw union members for J-type
variables, leading to invalid comparisons and potential pointer crash.

Impact:
JSON/local variables can now be compared against arrays and numbers
correctly in all rainerscript contexts.

Before/After:
Before, JSON variable inequality array matching only matched the first
element and numeric comparisons accessed wrong memory/pointers. Now,
array matching works for all elements, and numeric comparisons
correctly convert JSON types to numeric values.

Technical Overview:
1. Defer evaluation of right-hand expression in CMP_NE to check if
   it is a cnfarray before collapsing it.
2. Perform J-type check on the left-hand variable and invoke
   evalStrArrayCmp if the right-hand expression is an array.
3. Replace direct union access r.d.n with var2Number(&r, NULL)
   across CMP_EQ and CMP_NE to correctly handle numeric conversion
   for JSON-type variables.
4. Expand test case snd-array-cmp-json.sh with tests for numeric
   == and != comparisons on JSON variables.

Closes: https://github.com/rsyslog/rsyslog/issues/487

With the help of AI-Agents: Antigravity
2026-05-23 15:50:50 +02:00
..
2013-05-08 09:21:02 +02:00
2011-07-13 12:54:38 +02:00
2011-07-15 15:32:11 +02:00