Skip to content

Commit

Permalink
fix: GetCStrings to not use slices pkg and to only store ascii strings
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Jul 10, 2024
1 parent aa502a5 commit 0ca4a34
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 0ca4a34

Please # to comment.