From 52ca4a5c78383ed8f9b494ae9d2016c8ef9d2bce Mon Sep 17 00:00:00 2001 From: Ben Krochta Date: Sun, 20 Oct 2024 14:00:37 -0400 Subject: [PATCH] Fix input/output file comparison when signing 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. --- keys.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/keys.go b/keys.go index 70a3e9d..a857b5b 100644 --- a/keys.go +++ b/keys.go @@ -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 {