summaryrefslogtreecommitdiff
path: root/sshkey-xmss.c
diff options
context:
space:
mode:
authorderaadt@openbsd.org <deraadt@openbsd.org>2019-06-28 13:35:04 +0000
committerDamien Miller <djm@mindrot.org>2019-07-05 11:10:39 +1000
commit4d28fa78abce2890e136281950633fae2066cc29 (patch)
tree33226ec64ced661bb7e40005e30744b68fa59a80 /sshkey-xmss.c
parente8c974043c1648eab0ad67a7ba6a3e444fe79d2d (diff)
downloadopenssh-git-4d28fa78abce2890e136281950633fae2066cc29.tar.gz
upstream: When system calls indicate an error they return -1, not
some arbitrary value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future. OpenBSD-Commit-ID: 48081f00db7518e3b712a49dca06efc2a5428075
Diffstat (limited to 'sshkey-xmss.c')
-rw-r--r--sshkey-xmss.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sshkey-xmss.c b/sshkey-xmss.c
index ef39831c..a29e33f3 100644
--- a/sshkey-xmss.c
+++ b/sshkey-xmss.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshkey-xmss.c,v 1.4 2019/06/27 18:03:37 deraadt Exp $ */
+/* $OpenBSD: sshkey-xmss.c,v 1.5 2019/06/28 13:35:04 deraadt Exp $ */
/*
* Copyright (c) 2017 Markus Friedl. All rights reserved.
*
@@ -473,12 +473,12 @@ sshkey_xmss_get_state(const struct sshkey *k, sshkey_printfn *pr)
ret = SSH_ERR_ALLOC_FAIL;
goto done;
}
- if ((lockfd = open(lockfile, O_CREAT|O_RDONLY, 0600)) < 0) {
+ if ((lockfd = open(lockfile, O_CREAT|O_RDONLY, 0600)) == -1) {
ret = SSH_ERR_SYSTEM_ERROR;
PRINT("%s: cannot open/create: %s", __func__, lockfile);
goto done;
}
- while (flock(lockfd, LOCK_EX|LOCK_NB) < 0) {
+ while (flock(lockfd, LOCK_EX|LOCK_NB) == -1) {
if (errno != EWOULDBLOCK) {
ret = SSH_ERR_SYSTEM_ERROR;
PRINT("%s: cannot lock: %s", __func__, lockfile);
@@ -613,7 +613,7 @@ sshkey_xmss_update_state(const struct sshkey *k, sshkey_printfn *pr)
PRINT("%s: ENCRYPT FAILED: %d", __func__, ret);
goto done;
}
- if ((fd = open(nstatefile, O_CREAT|O_WRONLY|O_EXCL, 0600)) < 0) {
+ if ((fd = open(nstatefile, O_CREAT|O_WRONLY|O_EXCL, 0600)) == -1) {
ret = SSH_ERR_SYSTEM_ERROR;
PRINT("%s: open new state file: %s", __func__, nstatefile);
goto done;
@@ -632,13 +632,13 @@ sshkey_xmss_update_state(const struct sshkey *k, sshkey_printfn *pr)
close(fd);
goto done;
}
- if (fsync(fd) < 0) {
+ if (fsync(fd) == -1) {
ret = SSH_ERR_SYSTEM_ERROR;
PRINT("%s: sync new state file: %s", __func__, nstatefile);
close(fd);
goto done;
}
- if (close(fd) < 0) {
+ if (close(fd) == -1) {
ret = SSH_ERR_SYSTEM_ERROR;
PRINT("%s: close new state file: %s", __func__, nstatefile);
goto done;
@@ -652,7 +652,7 @@ sshkey_xmss_update_state(const struct sshkey *k, sshkey_printfn *pr)
goto done;
}
}
- if (rename(nstatefile, statefile) < 0) {
+ if (rename(nstatefile, statefile) == -1) {
ret = SSH_ERR_SYSTEM_ERROR;
PRINT("%s: rename %s to %s", __func__, nstatefile, statefile);
goto done;