Skip to content

Commit

Permalink
Fix input/output file comparison when signing
Browse files Browse the repository at this point in the history
Stat doesn't return ErrExist error, so this line is always false. We
also don't need any stats for the output file, so we can just try to
open the file, and continue the comparison with the input file if
there is no error opening it.
  • Loading branch information
bkrochta committed Oct 20, 2024
1 parent 53e074d commit 52ca4a5
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ func SignFile(state *config.State, kh *backend.KeyHierarchy, ev hierarchy.Hierar

// Check if the files are identical
if file != output {
if _, err := state.Fs.Stat(output); errors.Is(err, os.ErrExist) {
outputFile, err := state.Fs.Open(output)
if err != nil {
return err
}
if outputFile, err := state.Fs.Open(output); err == nil {
defer outputFile.Close()
outputBinary, err := authenticode.Parse(outputFile)
if err != nil {
Expand Down

0 comments on commit 52ca4a5

Please sign in to comment.