diff options
author | 2019-06-28 13:34:58 +0000 | |
---|---|---|
committer | 2019-06-28 13:34:58 +0000 | |
commit | 3aaa63eb46949490a39db9c6d82aacc8ee5d8551 (patch) | |
tree | ef48ea58ad350ab9d01fbfe32455a1df1fa2340c /usr.bin/ssh/sshconnect2.c | |
parent | fputc/fputs return EOF on error (diff) | |
download | wireguard-openbsd-3aaa63eb46949490a39db9c6d82aacc8ee5d8551.tar.xz wireguard-openbsd-3aaa63eb46949490a39db9c6d82aacc8ee5d8551.zip |
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.
Diffstat (limited to 'usr.bin/ssh/sshconnect2.c')
-rw-r--r-- | usr.bin/ssh/sshconnect2.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/ssh/sshconnect2.c b/usr.bin/ssh/sshconnect2.c index 123fb6c2818..0ccf0fb2646 100644 --- a/usr.bin/ssh/sshconnect2.c +++ b/usr.bin/ssh/sshconnect2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect2.c,v 1.305 2019/05/31 03:20:07 djm Exp $ */ +/* $OpenBSD: sshconnect2.c,v 1.306 2019/06/28 13:35:04 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2008 Damien Miller. All rights reserved. @@ -1400,7 +1400,7 @@ load_identity_file(Identity *id) int r, perm_ok = 0, quit = 0, i; struct stat st; - if (stat(id->filename, &st) < 0) { + if (stat(id->filename, &st) == -1) { (id->userprovided ? logit : debug3)("no such identity: %s: %s", id->filename, strerror(errno)); return NULL; @@ -1833,7 +1833,7 @@ ssh_keysign(struct ssh *ssh, struct sshkey *key, u_char **sigp, size_t *lenp, *sigp = NULL; *lenp = 0; - if (stat(_PATH_SSH_KEY_SIGN, &st) < 0) { + if (stat(_PATH_SSH_KEY_SIGN, &st) == -1) { error("%s: not installed: %s", __func__, strerror(errno)); return -1; } @@ -1841,30 +1841,30 @@ ssh_keysign(struct ssh *ssh, struct sshkey *key, u_char **sigp, size_t *lenp, error("%s: fflush: %s", __func__, strerror(errno)); return -1; } - if (pipe(to) < 0) { + if (pipe(to) == -1) { error("%s: pipe: %s", __func__, strerror(errno)); return -1; } - if (pipe(from) < 0) { + if (pipe(from) == -1) { error("%s: pipe: %s", __func__, strerror(errno)); return -1; } - if ((pid = fork()) < 0) { + if ((pid = fork()) == -1) { error("%s: fork: %s", __func__, strerror(errno)); return -1; } osigchld = signal(SIGCHLD, SIG_DFL); if (pid == 0) { close(from[0]); - if (dup2(from[1], STDOUT_FILENO) < 0) + if (dup2(from[1], STDOUT_FILENO) == -1) fatal("%s: dup2: %s", __func__, strerror(errno)); close(to[1]); - if (dup2(to[0], STDIN_FILENO) < 0) + if (dup2(to[0], STDIN_FILENO) == -1) fatal("%s: dup2: %s", __func__, strerror(errno)); close(from[1]); close(to[0]); - if (dup2(sock, STDERR_FILENO + 1) < 0) + if (dup2(sock, STDERR_FILENO + 1) == -1) fatal("%s: dup2: %s", __func__, strerror(errno)); sock = STDERR_FILENO + 1; fcntl(sock, F_SETFD, 0); /* keep the socket on exec */ @@ -1898,7 +1898,7 @@ ssh_keysign(struct ssh *ssh, struct sshkey *key, u_char **sigp, size_t *lenp, } errno = 0; - while (waitpid(pid, &status, 0) < 0) { + while (waitpid(pid, &status, 0) == -1) { if (errno != EINTR) { error("%s: waitpid %ld: %s", __func__, (long)pid, strerror(errno)); |