summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer2020-05-16 16:45:23 +0000
committerMatthias Schiffer2020-05-16 16:45:23 +0000
commit19f9e1917e1b458ed3b80d0d0295d62ae3ee3185 (patch)
treeacf791350112041c65340b85634d6928ee525e25
parent077feb5b5824beb3af28385d350e2398ffe46f27 (diff)
downloaducert-19f9e1917e1b458ed3b80d0d0295d62ae3ee3185.tar.gz
usign-exec: return code fixes
- WEXITSTATUS() should only be called when WIFEXITED() returns true - Fix double WEXITSTATUS() in usign_f() Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-rw-r--r--usign-exec.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usign-exec.c b/usign-exec.c
index 0dde81e..241d630 100644
--- a/usign-exec.c
+++ b/usign-exec.c
@@ -79,7 +79,7 @@ int usign_s(const char *msgfile, const char *seckeyfile, const char *sigfile, bo
}
waitpid(pid, &status, 0);
- return WEXITSTATUS(status);
+ return WIFEXITED(status) ? WEXITSTATUS(status) : -1;
}
#else
int usign_s(const char *msgfile, const char *seckeyfile, const char *sigfile, bool quiet) {
@@ -139,8 +139,9 @@ static int usign_f(char fingerprint[17], const char *pubkeyfile, const char *sec
close(fds[1]);
waitpid(pid, &status, 0);
- status = WEXITSTATUS(status);
- if (fingerprint && !WEXITSTATUS(status)) {
+ status = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
+
+ if (fingerprint && !status) {
ssize_t r;
memset(fingerprint, 0, 17);
r = read(fds[0], fingerprint, 17);
@@ -235,5 +236,5 @@ int usign_v(const char *msgfile, const char *pubkeyfile,
}
waitpid(pid, &status, 0);
- return WEXITSTATUS(status);
+ return WIFEXITED(status) ? WEXITSTATUS(status) : -1;
}