tetra: avoid panic in the decoder #2116
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We seem to be accessing Args[1] without a proper check. Add the check to avoid the panic.
panic: runtime error: index out of range [1] with length 1
goroutine 1 [running]:
github.com/cilium/tetragon/pkg/encoder.(*CompactEncoder).EventToString(0xc0001e0ec0, 0xc000894240)
/home/kkourt/src/tetragon/pkg/encoder/encoder.go:413 +0x4438
github.com/cilium/tetragon/pkg/encoder.(*CompactEncoder).Encode(0xc0001e0ec0, {0x1c83480?, 0xc000894240})
/home/kkourt/src/tetragon/pkg/encoder/encoder.go:110 +0x9f
github.com/cilium/tetragon/cmd/tetra/getevents.getEvents({0x204cd20, 0xc000388840}, {0x205ba68, 0xc0007aec00})
/home/kkourt/src/tetragon/cmd/tetra/getevents/getevents.go:150 +0x4dd
github.com/cilium/tetragon/cmd/tetra/common.CliRunErr(0x1e4b3c8, 0x1e4b3c0)
/home/kkourt/src/tetragon/cmd/tetra/common/client.go:95 +0x68a
github.com/cilium/tetragon/cmd/tetra/common.CliRun(...)
/home/kkourt/src/tetragon/cmd/tetra/common/client.go:99
github.com/cilium/tetragon/cmd/tetra/getevents.New.func2(0xc0002e6a00?, {0x1d275fd?, 0x4?, 0x1d27601?})
/home/kkourt/src/tetragon/cmd/tetra/getevents/getevents.go:195 +0x108
github.com/spf13/cobra.(*Command).execute(0xc000193b08, {0xc0001e03a0, 0x2, 0x2})
/home/kkourt/src/tetragon/vendor/github.com/spf13/cobra/command.go:987 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0xc000193808)
/home/kkourt/src/tetragon/vendor/github.com/spf13/cobra/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
/home/kkourt/src/tetragon/vendor/github.com/spf13/cobra/command.go:1039
main.main()
/home/kkourt/src/tetragon/cmd/tetra/main.go:21 +0x18