Files
yq/pkg/yqlib
80139ae1cc Fix panic on negative slice indices that underflow after adjustment (#2646)
sliceArrayOperator adjusts negative indices by adding Content length,
but does not clamp the result. When the absolute value of a negative
index exceeds Content length (e.g. .[-99999:3] on a 3-element array),
the adjusted index remains negative and causes an out-of-bounds access
in the Content slice loop.

Extract the adjust-and-clamp logic into clampSliceIndex and use it for
both index positions.

Reproducer (panics before this fix, returns full array after):

    echo '[a, b, c]' | yq '.[-99999:3]'

Found by OSS-Fuzz via the lima project's FuzzEvaluateExpression target.
https://issues.oss-fuzz.com/issues/438776028

Signed-off-by: Jan Dubois <jan@jandubois.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 18:27:02 +10:00
..
2023-10-18 12:11:53 +11:00
2025-12-08 21:09:21 +11:00
2025-12-20 19:11:48 +11:00
2023-10-18 12:11:53 +11:00
2023-10-18 12:11:53 +11:00
2026-02-01 10:27:18 +11:00
2025-12-20 19:11:48 +11:00
2025-12-20 19:11:48 +11:00
2025-05-17 18:55:53 +10:00
2024-02-24 15:48:59 +11:00
2025-05-03 16:34:21 +10:00
2025-06-07 15:23:38 +10:00
2026-02-01 10:27:18 +11:00
2025-12-08 20:30:47 +11:00
2025-05-17 18:55:53 +10:00
2025-05-17 18:55:53 +10:00
2024-02-24 15:59:12 +11:00
2025-11-25 10:17:43 +11:00
2024-02-24 15:36:16 +11:00
2023-10-18 12:11:53 +11:00
2025-12-08 20:30:47 +11:00
2023-10-03 16:22:23 +11:00
2025-12-26 11:08:24 +11:00
2025-06-12 15:41:27 +10:00
2023-10-18 12:11:53 +11:00
2024-01-11 13:17:34 +11:00
2023-10-18 12:11:53 +11:00
2022-11-01 09:29:05 +11:00
2024-01-11 13:17:34 +11:00
2023-10-18 12:11:53 +11:00
2023-10-18 12:11:53 +11:00
2024-01-11 13:17:34 +11:00
2023-10-18 12:11:53 +11:00
2023-10-18 12:11:53 +11:00
2024-11-16 11:48:53 +11:00
2023-10-18 12:11:53 +11:00
2024-01-11 13:17:34 +11:00
2025-11-09 16:12:17 +11:00
2025-11-09 16:12:17 +11:00
2023-10-18 12:11:53 +11:00
2023-10-02 14:43:12 +11:00
2024-01-11 13:17:34 +11:00
2023-03-16 13:39:36 +11:00
2024-01-11 13:17:34 +11:00
2023-10-18 12:11:53 +11:00
2024-01-11 13:17:34 +11:00
2025-05-03 16:34:21 +10:00
2025-05-03 16:34:21 +10:00
2025-05-03 16:34:21 +10:00
2023-10-18 12:11:53 +11:00
2024-03-30 13:29:35 +11:00
2024-01-11 13:17:34 +11:00
2024-01-11 13:17:34 +11:00
2023-10-18 12:11:53 +11:00
2025-06-07 15:23:38 +10:00
2023-10-18 12:11:53 +11:00
2024-01-11 13:17:34 +11:00
2023-10-18 12:11:53 +11:00
2025-06-07 15:23:38 +10:00
2024-06-15 17:06:17 +10:00
2023-10-18 12:11:53 +11:00
2026-02-01 10:27:18 +11:00
2025-12-20 19:11:48 +11:00
2025-05-03 16:34:21 +10:00
2024-02-24 15:14:21 +11:00
2024-02-21 14:50:55 +11:00
2025-12-14 19:41:45 +11:00
2024-02-24 15:03:30 +11:00
2025-12-06 19:08:37 +11:00