Skip to content

Commit

Permalink
Make code to handle .class files a bit clearer
Browse files Browse the repository at this point in the history
(but don't use defer)

Close #3
  • Loading branch information
hillu committed Dec 12, 2021
1 parent 39e903f commit a152804
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions log4j-vuln-finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ func handleJar(path string, ra io.ReaderAt, sz int64) {
continue
}
hasher := sha256.New()
if _, err := io.Copy(hasher, fr); err != nil {
_, err = io.Copy(hasher, fr)
fr.Close()
if err != nil {
fmt.Printf("can't read JAR file member: %s (%s): %v\n", path, file.Name, err)
} else {
sum := hex.EncodeToString(hasher.Sum(nil))
if desc, ok := vulnVersions[sum]; ok {
fmt.Printf("indicator for vulnerable component found in %s (%s): %s\n", path, file.Name, desc)
}
}
fr.Close()
sum := hex.EncodeToString(hasher.Sum(nil))
if desc, ok := vulnVersions[sum]; ok {
fmt.Printf("indicator for vulnerable component found in %s (%s): %s\n", path, file.Name, desc)
}
case ".jar", ".war":
fr, err := file.Open()
if err != nil {
Expand Down

0 comments on commit a152804

Please sign in to comment.