Commit ac39201b authored by Sietse Ringers's avatar Sietse Ringers
Browse files

feat: check errors when closing files in keyproof

parent 3fe5754e
......@@ -228,11 +228,11 @@ The keyprove command generates a proof that an issuer key was generated correctl
if err != nil {
die("Error opening proof file for writing", err)
}
defer proofOut.Close()
defer closeCloser(proofOut)
// Wrap it for gzip compression
proofWriter := gzip.NewWriter(proofOut)
defer proofWriter.Close()
defer closeCloser(proofWriter)
// Start log follower
follower := startLogFollower()
......
......@@ -4,6 +4,7 @@ import (
"compress/gzip"
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
"strconv"
......@@ -78,13 +79,13 @@ The keyverify command verifies proofs of validity for IRMA issuer keys. By defau
follower.StepDone()
die("Error opening proof", err)
}
defer proofFile.Close()
defer closeCloser(proofFile)
proofGzip, err := gzip.NewReader(proofFile)
if err != nil {
follower.StepDone()
die("Error reading proof data", err)
}
defer proofGzip.Close()
defer closeCloser(proofGzip)
proofDecoder := json.NewDecoder(proofGzip)
var proof keyproof.ValidKeyProof
err = proofDecoder.Decode(&proof)
......@@ -106,6 +107,12 @@ The keyverify command verifies proofs of validity for IRMA issuer keys. By defau
},
}
func closeCloser(c io.Closer) {
if err := c.Close(); err != nil {
die("", err)
}
}
func lastPrivateKeyIndex(path string) (counter int) {
matches, _ := filepath.Glob(filepath.Join(path, "PrivateKeys", "*.xml"))
for _, match := range matches {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment