From 167bbe374162d0bb40ddaccc6676f3df27dd36e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Mert=20Y=C4=B1ld=C4=B1ran?= Date: Sun, 19 Jun 2022 02:19:32 -0700 Subject: [PATCH] Fix a `slice bounds out of range` panic in Go offsets calculation (#1155) * Fix a `slice bounds out of range` error in Go offsets calculation * Change `Errorf` to `Warningf` --- tap/tlstapper/go_offsets.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tap/tlstapper/go_offsets.go b/tap/tlstapper/go_offsets.go index 239b76bc2..a963d9077 100644 --- a/tap/tlstapper/go_offsets.go +++ b/tap/tlstapper/go_offsets.go @@ -10,6 +10,7 @@ import ( "github.com/Masterminds/semver" "github.com/cilium/ebpf/link" "github.com/knightsc/gapstone" + "github.com/up9inc/mizu/logger" ) type goOffsets struct { @@ -145,6 +146,16 @@ func getOffsets(filePath string) (offsets map[string]*goExtendedOffset, err erro symEndingIndex := symStartingIndex + sym.Size // collect the bytes of the symbol + textSectionDataLen := uint64(len(textSectionData) - 1) + if symEndingIndex > textSectionDataLen { + logger.Log.Warningf( + "Skipping symbol %v, ending index %v is bigger than text section data length %v", + sym.Name, + symEndingIndex, + textSectionDataLen, + ) + continue + } symBytes := textSectionData[symStartingIndex:symEndingIndex] // disasemble the symbol