Skip to content

Commit

Permalink
Fix error resulting in "can't read magic" errors for empty/short files
Browse files Browse the repository at this point in the history
Close #29
  • Loading branch information
hillu committed Dec 16, 2021
1 parent 6239f06 commit 66e942a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions scanner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ func handleJar(path string, ra io.ReaderAt, sz int64) {
// Identify class filess by magic bytes
buf := bytes.NewBuffer(nil)
if _, err := io.CopyN(buf, fr, 4); err != nil {
if err == io.EOF {
if !quiet {
fmt.Fprintf(logFile, "can't read magic from JAR file member: %s (%s): %v\n", path, file.Name, err)
}
if err != io.EOF && !quiet {
fmt.Fprintf(logFile, "can't read magic from JAR file member: %s (%s): %v\n", path, file.Name, err)
}
fr.Close()
continue
Expand Down

0 comments on commit 66e942a

Please sign in to comment.