diff mbox series

[18/20] fsverity_cmd_sign() don't exit on error without closing file descriptor

Message ID 20200424205504.2586682-19-Jes.Sorensen@gmail.com (mailing list archive)
State Superseded
Headers show
Series Split fsverity-utils into a shared library | expand

Commit Message

Jes Sorensen April 24, 2020, 8:55 p.m. UTC
From: Jes Sorensen <jsorensen@fb.com>

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
 cmd_sign.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/cmd_sign.c b/cmd_sign.c
index d699d85..7d8ec58 100644
--- a/cmd_sign.c
+++ b/cmd_sign.c
@@ -73,7 +73,7 @@  int fsverity_cmd_sign(const struct fsverity_command *cmd,
 	u16 alg_nr = 0;
 	int digest_size;
 	size_t sig_size;
-	int status;
+	int status, ret;
 	int c;
 
 	while ((c = getopt_long(argc, argv, "", longopts, NULL)) != -1) {
@@ -154,12 +154,13 @@  int fsverity_cmd_sign(const struct fsverity_command *cmd,
 	params.salt_size = salt_size;
 	params.salt = salt;
 
-	if (libfsverity_compute_digest(&file, file_size, read_callback,
-				       &params, &digest))
-		goto out_err;
-
+	ret = libfsverity_compute_digest(&file, file_size, read_callback,
+					 &params, &digest);
 	filedes_close(&file);
 
+	if (ret)
+		goto out_err;
+
 	digest_size = libfsverity_digest_size(alg_nr);
 
 	memset(&sig_params, 0, sizeof(sig_params));