diff options
author | deraadt@openbsd.org <deraadt@openbsd.org> | 2019-06-28 13:35:04 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2019-07-05 11:10:39 +1000 |
commit | 4d28fa78abce2890e136281950633fae2066cc29 (patch) | |
tree | 33226ec64ced661bb7e40005e30744b68fa59a80 /sshconnect2.c | |
parent | e8c974043c1648eab0ad67a7ba6a3e444fe79d2d (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 'sshconnect2.c')
-rw-r--r-- | sshconnect2.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sshconnect2.c b/sshconnect2.c index 0d2523ca1..0ad44ce19 100644 --- a/sshconnect2.c +++ b/sshconnect2.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshconnect2.c,v 1.305 2019/05/31 03:20:07 djm Exp $ */ | 1 | /* $OpenBSD: sshconnect2.c,v 1.306 2019/06/28 13:35:04 deraadt Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2008 Damien Miller. All rights reserved. | 4 | * Copyright (c) 2008 Damien Miller. All rights reserved. |
@@ -1408,7 +1408,7 @@ load_identity_file(Identity *id) | |||
1408 | int r, perm_ok = 0, quit = 0, i; | 1408 | int r, perm_ok = 0, quit = 0, i; |
1409 | struct stat st; | 1409 | struct stat st; |
1410 | 1410 | ||
1411 | if (stat(id->filename, &st) < 0) { | 1411 | if (stat(id->filename, &st) == -1) { |
1412 | (id->userprovided ? logit : debug3)("no such identity: %s: %s", | 1412 | (id->userprovided ? logit : debug3)("no such identity: %s: %s", |
1413 | id->filename, strerror(errno)); | 1413 | id->filename, strerror(errno)); |
1414 | return NULL; | 1414 | return NULL; |
@@ -1841,7 +1841,7 @@ ssh_keysign(struct ssh *ssh, struct sshkey *key, u_char **sigp, size_t *lenp, | |||
1841 | *sigp = NULL; | 1841 | *sigp = NULL; |
1842 | *lenp = 0; | 1842 | *lenp = 0; |
1843 | 1843 | ||
1844 | if (stat(_PATH_SSH_KEY_SIGN, &st) < 0) { | 1844 | if (stat(_PATH_SSH_KEY_SIGN, &st) == -1) { |
1845 | error("%s: not installed: %s", __func__, strerror(errno)); | 1845 | error("%s: not installed: %s", __func__, strerror(errno)); |
1846 | return -1; | 1846 | return -1; |
1847 | } | 1847 | } |
@@ -1849,30 +1849,30 @@ ssh_keysign(struct ssh *ssh, struct sshkey *key, u_char **sigp, size_t *lenp, | |||
1849 | error("%s: fflush: %s", __func__, strerror(errno)); | 1849 | error("%s: fflush: %s", __func__, strerror(errno)); |
1850 | return -1; | 1850 | return -1; |
1851 | } | 1851 | } |
1852 | if (pipe(to) < 0) { | 1852 | if (pipe(to) == -1) { |
1853 | error("%s: pipe: %s", __func__, strerror(errno)); | 1853 | error("%s: pipe: %s", __func__, strerror(errno)); |
1854 | return -1; | 1854 | return -1; |
1855 | } | 1855 | } |
1856 | if (pipe(from) < 0) { | 1856 | if (pipe(from) == -1) { |
1857 | error("%s: pipe: %s", __func__, strerror(errno)); | 1857 | error("%s: pipe: %s", __func__, strerror(errno)); |
1858 | return -1; | 1858 | return -1; |
1859 | } | 1859 | } |
1860 | if ((pid = fork()) < 0) { | 1860 | if ((pid = fork()) == -1) { |
1861 | error("%s: fork: %s", __func__, strerror(errno)); | 1861 | error("%s: fork: %s", __func__, strerror(errno)); |
1862 | return -1; | 1862 | return -1; |
1863 | } | 1863 | } |
1864 | osigchld = signal(SIGCHLD, SIG_DFL); | 1864 | osigchld = signal(SIGCHLD, SIG_DFL); |
1865 | if (pid == 0) { | 1865 | if (pid == 0) { |
1866 | close(from[0]); | 1866 | close(from[0]); |
1867 | if (dup2(from[1], STDOUT_FILENO) < 0) | 1867 | if (dup2(from[1], STDOUT_FILENO) == -1) |
1868 | fatal("%s: dup2: %s", __func__, strerror(errno)); | 1868 | fatal("%s: dup2: %s", __func__, strerror(errno)); |
1869 | close(to[1]); | 1869 | close(to[1]); |
1870 | if (dup2(to[0], STDIN_FILENO) < 0) | 1870 | if (dup2(to[0], STDIN_FILENO) == -1) |
1871 | fatal("%s: dup2: %s", __func__, strerror(errno)); | 1871 | fatal("%s: dup2: %s", __func__, strerror(errno)); |
1872 | close(from[1]); | 1872 | close(from[1]); |
1873 | close(to[0]); | 1873 | close(to[0]); |
1874 | 1874 | ||
1875 | if (dup2(sock, STDERR_FILENO + 1) < 0) | 1875 | if (dup2(sock, STDERR_FILENO + 1) == -1) |
1876 | fatal("%s: dup2: %s", __func__, strerror(errno)); | 1876 | fatal("%s: dup2: %s", __func__, strerror(errno)); |
1877 | sock = STDERR_FILENO + 1; | 1877 | sock = STDERR_FILENO + 1; |
1878 | fcntl(sock, F_SETFD, 0); /* keep the socket on exec */ | 1878 | fcntl(sock, F_SETFD, 0); /* keep the socket on exec */ |
@@ -1906,7 +1906,7 @@ ssh_keysign(struct ssh *ssh, struct sshkey *key, u_char **sigp, size_t *lenp, | |||
1906 | } | 1906 | } |
1907 | 1907 | ||
1908 | errno = 0; | 1908 | errno = 0; |
1909 | while (waitpid(pid, &status, 0) < 0) { | 1909 | while (waitpid(pid, &status, 0) == -1) { |
1910 | if (errno != EINTR) { | 1910 | if (errno != EINTR) { |
1911 | error("%s: waitpid %ld: %s", | 1911 | error("%s: waitpid %ld: %s", |
1912 | __func__, (long)pid, strerror(errno)); | 1912 | __func__, (long)pid, strerror(errno)); |