mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-06-15 19:52:39 +02:00
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