Skip to content

Commit

Permalink
Merge pull request #3117 from nzspambot/jbaker/fix-hook-check
Browse files Browse the repository at this point in the history
fix: allow for empty files on hook check
  • Loading branch information
DrJosh9000 authored Dec 4, 2024
2 parents 00ca79f + 8a5a623 commit e948232
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/job/hook/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ func isBinaryExecutable(path string) (bool, error) {
}

defer f.Close()

fileInfo, err := f.Stat()
if err != nil {
return false, fmt.Errorf("stat file %q: %w", path, err)
}

if fileInfo.Size() < 4 {
// there are less than four bytes in the file, we assume it is an empty file and there's nothing that we can do with it
return false, nil
}

r := bufio.NewReader(f)
firstFour, err := r.Peek(4)
if err != nil {
Expand Down

0 comments on commit e948232

Please sign in to comment.