From 15e2612c090ec7e205991846bf839781682f3f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geyslan=20Greg=C3=B3rio?= Date: Tue, 17 Sep 2024 16:32:52 -0300 Subject: [PATCH] fix(tests): possible out of range in integration ExpectAllInOrderSequentially might try to access an index out of range depending on the number of events that are being checked. More about in issue #4255. --- tests/integration/event_filters_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/integration/event_filters_test.go b/tests/integration/event_filters_test.go index d47f1522df71..420fa1f24131 100644 --- a/tests/integration/event_filters_test.go +++ b/tests/integration/event_filters_test.go @@ -2469,8 +2469,9 @@ func ExpectAllInOrderSequentially(t *testing.T, cmdEvents []cmdEvents, actual *e actEvtsCopy := actual.getCopy() + actEvtIdx := 0 // second stage: check events - for cmdIdx, cmd := range cmdEvents { + for _, cmd := range cmdEvents { syscallsInSets := []string{} checkSets := len(cmd.sets) > 0 if checkSets { @@ -2478,8 +2479,9 @@ func ExpectAllInOrderSequentially(t *testing.T, cmdEvents []cmdEvents, actual *e } // compare the expected events with the actual events in the same order - for evtIdx, expEvt := range cmd.expectedEvents { - actEvt := actEvtsCopy[cmdIdx*len(cmd.expectedEvents)+evtIdx] + for _, expEvt := range cmd.expectedEvents { + actEvt := actEvtsCopy[actEvtIdx] + actEvtIdx++ if checkSets && !isInSets(actEvt.EventName, syscallsInSets) { return fmt.Errorf("Event %s not found in sets %v", actEvt.EventName, cmd.sets)