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)
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 ef39831c6..a29e33f39 100644
--- a/sshkey-xmss.c
+++ b/sshkey-xmss.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshkey-xmss.c,v 1.4 2019/06/27 18:03:37 deraadt Exp $ */ 1/* $OpenBSD: sshkey-xmss.c,v 1.5 2019/06/28 13:35:04 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2017 Markus Friedl. All rights reserved. 3 * Copyright (c) 2017 Markus Friedl. All rights reserved.
4 * 4 *
@@ -473,12 +473,12 @@ sshkey_xmss_get_state(const struct sshkey *k, sshkey_printfn *pr)
473 ret = SSH_ERR_ALLOC_FAIL; 473 ret = SSH_ERR_ALLOC_FAIL;
474 goto done; 474 goto done;
475 } 475 }
476 if ((lockfd = open(lockfile, O_CREAT|O_RDONLY, 0600)) < 0) { 476 if ((lockfd = open(lockfile, O_CREAT|O_RDONLY, 0600)) == -1) {
477 ret = SSH_ERR_SYSTEM_ERROR; 477 ret = SSH_ERR_SYSTEM_ERROR;
478 PRINT("%s: cannot open/create: %s", __func__, lockfile); 478 PRINT("%s: cannot open/create: %s", __func__, lockfile);
479 goto done; 479 goto done;
480 } 480 }
481 while (flock(lockfd, LOCK_EX|LOCK_NB) < 0) { 481 while (flock(lockfd, LOCK_EX|LOCK_NB) == -1) {
482 if (errno != EWOULDBLOCK) { 482 if (errno != EWOULDBLOCK) {
483 ret = SSH_ERR_SYSTEM_ERROR; 483 ret = SSH_ERR_SYSTEM_ERROR;
484 PRINT("%s: cannot lock: %s", __func__, lockfile); 484 PRINT("%s: cannot lock: %s", __func__, lockfile);
@@ -613,7 +613,7 @@ sshkey_xmss_update_state(const struct sshkey *k, sshkey_printfn *pr)
613 PRINT("%s: ENCRYPT FAILED: %d", __func__, ret); 613 PRINT("%s: ENCRYPT FAILED: %d", __func__, ret);
614 goto done; 614 goto done;
615 } 615 }
616 if ((fd = open(nstatefile, O_CREAT|O_WRONLY|O_EXCL, 0600)) < 0) { 616 if ((fd = open(nstatefile, O_CREAT|O_WRONLY|O_EXCL, 0600)) == -1) {
617 ret = SSH_ERR_SYSTEM_ERROR; 617 ret = SSH_ERR_SYSTEM_ERROR;
618 PRINT("%s: open new state file: %s", __func__, nstatefile); 618 PRINT("%s: open new state file: %s", __func__, nstatefile);
619 goto done; 619 goto done;
@@ -632,13 +632,13 @@ sshkey_xmss_update_state(const struct sshkey *k, sshkey_printfn *pr)
632 close(fd); 632 close(fd);
633 goto done; 633 goto done;
634 } 634 }
635 if (fsync(fd) < 0) { 635 if (fsync(fd) == -1) {
636 ret = SSH_ERR_SYSTEM_ERROR; 636 ret = SSH_ERR_SYSTEM_ERROR;
637 PRINT("%s: sync new state file: %s", __func__, nstatefile); 637 PRINT("%s: sync new state file: %s", __func__, nstatefile);
638 close(fd); 638 close(fd);
639 goto done; 639 goto done;
640 } 640 }
641 if (close(fd) < 0) { 641 if (close(fd) == -1) {
642 ret = SSH_ERR_SYSTEM_ERROR; 642 ret = SSH_ERR_SYSTEM_ERROR;
643 PRINT("%s: close new state file: %s", __func__, nstatefile); 643 PRINT("%s: close new state file: %s", __func__, nstatefile);
644 goto done; 644 goto done;
@@ -652,7 +652,7 @@ sshkey_xmss_update_state(const struct sshkey *k, sshkey_printfn *pr)
652 goto done; 652 goto done;
653 } 653 }
654 } 654 }
655 if (rename(nstatefile, statefile) < 0) { 655 if (rename(nstatefile, statefile) == -1) {
656 ret = SSH_ERR_SYSTEM_ERROR; 656 ret = SSH_ERR_SYSTEM_ERROR;
657 PRINT("%s: rename %s to %s", __func__, nstatefile, statefile); 657 PRINT("%s: rename %s to %s", __func__, nstatefile, statefile);
658 goto done; 658 goto done;