Skip to content

Commit

Permalink
fix: update graalvm cataloger to fix panic (#1454)
Browse files Browse the repository at this point in the history
Fixes #1453
  • Loading branch information
kzantow authored Jan 12, 2023
1 parent e87cfe7 commit ac94bf5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions syft/pkg/cataloger/java/graalvm_native_image_cataloger.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,15 @@ func newPE(filename string, r io.ReaderAt) (nativeImage, error) {
if err != nil {
return fileError(filename, err)
}
optionalHeader := bi.OptionalHeader.(*pe.OptionalHeader64)
exportSymbolsDataDirectory := optionalHeader.DataDirectory[0]
var exportSymbolsDataDirectory pe.DataDirectory
switch h := bi.OptionalHeader.(type) {
case *pe.OptionalHeader32:
exportSymbolsDataDirectory = h.DataDirectory[0]
case *pe.OptionalHeader64:
exportSymbolsDataDirectory = h.DataDirectory[0]
default:
return nil, fmt.Errorf("unable to get exportSymbolsDataDirectory from binary: %s", filename)
}
// If we have no exported symbols it is not a Native Image
if exportSymbolsDataDirectory.Size == 0 {
return fileError(filename, errors.New(nativeImageMissingExportedDataDirectoryError))
Expand Down

0 comments on commit ac94bf5

Please sign in to comment.