From 0ca4a34a2397a191ffd7762ad52b5c8d1fda846f Mon Sep 17 00:00:00 2001 From: blacktop Date: Wed, 10 Jul 2024 10:27:19 -0600 Subject: [PATCH] fix: GetCStrings to not use slices pkg and to only store ascii strings --- file.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/file.go b/file.go index 50ea103..76dbbd3 100644 --- a/file.go +++ b/file.go @@ -13,11 +13,12 @@ import ( "log" "os" "path/filepath" + "sort" "strings" "sync" + "unicode" "github.com/blacktop/go-dwarf" - "golang.org/x/exp/slices" "github.com/blacktop/go-macho/internal/saferio" "github.com/blacktop/go-macho/pkg/codesign" @@ -1675,10 +1676,15 @@ func (f *File) GetCStrings() ([]string, error) { s = strings.Trim(s, "\x00") if len(s) > 0 { + for _, r := range s { + if r > unicode.MaxASCII || !unicode.IsPrint(r) { + continue // skip non-ascii strings + } + } strs = append(strs, s) } } - slices.Sort(strs) + sort.Strings(strs) } }