Skip to content

Commit

Permalink
chore: revert XCOFF changes
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
  • Loading branch information
spiffcs committed Jun 5, 2023
1 parent ba38b97 commit 4a2b9cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions internal/file/zip_file_traversal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func prependZipSourceFixtureWithString(tb testing.TB, value string) func(tb test
archivePath := prepZipSourceFixture(t)

// create a temp file
tmpFile, err := os.CreateTemp("", "syft-ziputil-prependZipSourceFixtureWithString-")
tmpFile, err := os.CreateTemp(tb.TempDir(), "syft-ziputil-prependZipSourceFixtureWithString-")
if err != nil {
t.Fatalf("unable to create tempfile: %+v", err)
}
Expand Down Expand Up @@ -205,11 +205,11 @@ func prepZipSourceFixture(t testing.TB) string {
archivePrefix := path.Join(t.TempDir(), "syft-ziputil-prepZipSourceFixture-")

// the zip utility will add ".zip" to the end of the given name
archivePath := archivePrefix.Name() + ".zip"
archivePath := archivePrefix + ".zip"

t.Logf("archive path: %s", archivePath)

createZipArchive(t, "zip-source", archivePrefix.Name(), false)
createZipArchive(t, "zip-source", archivePrefix, false)

return archivePath
}
Expand Down
26 changes: 13 additions & 13 deletions syft/pkg/cataloger/golang/internal/xcoff/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
f.TargetMachine = magic

// Read XCOFF file header
if _, err := sr.Seek(0, io.SeekStart); err != nil {
if _, err := sr.Seek(0, os.SEEK_SET); err != nil {
return nil, err
}
var nscns uint16
Expand Down Expand Up @@ -205,7 +205,7 @@ func NewFile(r io.ReaderAt) (*File, error) {

// Read string table (located right after symbol table).
offset := symptr + uint64(nsyms)*SYMESZ
if _, err := sr.Seek(int64(offset), io.SeekStart); err != nil {
if _, err := sr.Seek(int64(offset), os.SEEK_SET); err != nil {
return nil, err
}
// The first 4 bytes contain the length (in bytes).
Expand All @@ -214,7 +214,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
return nil, err
}
if l > 4 {
if _, err := sr.Seek(int64(offset), io.SeekStart); err != nil {
if _, err := sr.Seek(int64(offset), os.SEEK_SET); err != nil {
return nil, err
}
f.StringTable = make([]byte, l)
Expand All @@ -224,7 +224,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
}

// Read section headers
if _, err := sr.Seek(int64(hdrsz)+int64(opthdr), io.SeekStart); err != nil {
if _, err := sr.Seek(int64(hdrsz)+int64(opthdr), os.SEEK_SET); err != nil {
return nil, err
}
f.Sections = make([]*Section, nscns)
Expand Down Expand Up @@ -270,7 +270,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
var idxToSym = make(map[int]*Symbol)

// Read symbol table
if _, err := sr.Seek(int64(symptr), io.SeekStart); err != nil {
if _, err := sr.Seek(int64(symptr), os.SEEK_SET); err != nil {
return nil, err
}
f.Symbols = make([]*Symbol, 0)
Expand Down Expand Up @@ -356,7 +356,7 @@ func NewFile(r io.ReaderAt) (*File, error) {

// Read csect auxiliary entry (by convention, it is the last).
if !needAuxFcn {
if _, err := sr.Seek(int64(numaux-1)*SYMESZ, io.SeekStart); err != nil {
if _, err := sr.Seek(int64(numaux-1)*SYMESZ, os.SEEK_CUR); err != nil {
return nil, err
}
}
Expand All @@ -383,7 +383,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
f.Symbols = append(f.Symbols, sym)
skip:
i += numaux // Skip auxiliary entries
if _, err := sr.Seek(int64(numaux)*SYMESZ, io.SeekStart); err != nil {
if _, err := sr.Seek(int64(numaux)*SYMESZ, os.SEEK_CUR); err != nil {
return nil, err
}
}
Expand All @@ -398,7 +398,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
if sect.Relptr == 0 {
continue
}
if _, err := sr.Seek(int64(sect.Relptr), io.SeekStart); err != nil {
if _, err := sr.Seek(int64(sect.Relptr), os.SEEK_SET); err != nil {
return nil, err
}
for i := uint32(0); i < sect.Nreloc; i++ {
Expand Down Expand Up @@ -509,7 +509,7 @@ func (s *Section) Data() ([]byte, error) {
// Library name pattern is either path/base/member or base/member
func (f *File) readImportIDs(s *Section) ([]string, error) {
// Read loader header
if _, err := s.sr.Seek(0, io.SeekStart); err != nil {
if _, err := s.sr.Seek(0, os.SEEK_SET); err != nil {
return nil, err
}
var istlen uint32
Expand All @@ -535,7 +535,7 @@ func (f *File) readImportIDs(s *Section) ([]string, error) {
}

// Read loader import file ID table
if _, err := s.sr.Seek(int64(impoff), io.SeekStart); err != nil {
if _, err := s.sr.Seek(int64(impoff), os.SEEK_SET); err != nil {
return nil, err
}
table := make([]byte, istlen)
Expand Down Expand Up @@ -578,7 +578,7 @@ func (f *File) ImportedSymbols() ([]ImportedSymbol, error) {
return nil, nil
}
// Read loader header
if _, err := s.sr.Seek(0, io.SeekStart); err != nil {
if _, err := s.sr.Seek(0, os.SEEK_SET); err != nil {
return nil, err
}
var stlen uint32
Expand Down Expand Up @@ -607,7 +607,7 @@ func (f *File) ImportedSymbols() ([]ImportedSymbol, error) {
}

// Read loader section string table
if _, err := s.sr.Seek(int64(stoff), io.SeekStart); err != nil {
if _, err := s.sr.Seek(int64(stoff), os.SEEK_SET); err != nil {
return nil, err
}
st := make([]byte, stlen)
Expand All @@ -622,7 +622,7 @@ func (f *File) ImportedSymbols() ([]ImportedSymbol, error) {
}

// Read loader symbol table
if _, err := s.sr.Seek(int64(symoff), io.SeekStart); err != nil {
if _, err := s.sr.Seek(int64(symoff), os.SEEK_SET); err != nil {
return nil, err
}
all := make([]ImportedSymbol, 0)
Expand Down

0 comments on commit 4a2b9cc

Please sign in to comment.