summaryrefslogtreecommitdiff
path: root/readpass.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 /readpass.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 'readpass.c')
-rw-r--r--readpass.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/readpass.c b/readpass.c
index 44014ef8a..7e52cae9c 100644
--- a/readpass.c
+++ b/readpass.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readpass.c,v 1.53 2019/01/19 04:15:56 tb Exp $ */ 1/* $OpenBSD: readpass.c,v 1.54 2019/06/28 13:35:04 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -61,19 +61,19 @@ ssh_askpass(char *askpass, const char *msg)
61 error("ssh_askpass: fflush: %s", strerror(errno)); 61 error("ssh_askpass: fflush: %s", strerror(errno));
62 if (askpass == NULL) 62 if (askpass == NULL)
63 fatal("internal error: askpass undefined"); 63 fatal("internal error: askpass undefined");
64 if (pipe(p) < 0) { 64 if (pipe(p) == -1) {
65 error("ssh_askpass: pipe: %s", strerror(errno)); 65 error("ssh_askpass: pipe: %s", strerror(errno));
66 return NULL; 66 return NULL;
67 } 67 }
68 osigchld = signal(SIGCHLD, SIG_DFL); 68 osigchld = signal(SIGCHLD, SIG_DFL);
69 if ((pid = fork()) < 0) { 69 if ((pid = fork()) == -1) {
70 error("ssh_askpass: fork: %s", strerror(errno)); 70 error("ssh_askpass: fork: %s", strerror(errno));
71 signal(SIGCHLD, osigchld); 71 signal(SIGCHLD, osigchld);
72 return NULL; 72 return NULL;
73 } 73 }
74 if (pid == 0) { 74 if (pid == 0) {
75 close(p[0]); 75 close(p[0]);
76 if (dup2(p[1], STDOUT_FILENO) < 0) 76 if (dup2(p[1], STDOUT_FILENO) == -1)
77 fatal("ssh_askpass: dup2: %s", strerror(errno)); 77 fatal("ssh_askpass: dup2: %s", strerror(errno));
78 execlp(askpass, askpass, msg, (char *)NULL); 78 execlp(askpass, askpass, msg, (char *)NULL);
79 fatal("ssh_askpass: exec(%s): %s", askpass, strerror(errno)); 79 fatal("ssh_askpass: exec(%s): %s", askpass, strerror(errno));
@@ -93,7 +93,7 @@ ssh_askpass(char *askpass, const char *msg)
93 buf[len] = '\0'; 93 buf[len] = '\0';
94 94
95 close(p[0]); 95 close(p[0]);
96 while ((ret = waitpid(pid, &status, 0)) < 0) 96 while ((ret = waitpid(pid, &status, 0)) == -1)
97 if (errno != EINTR) 97 if (errno != EINTR)
98 break; 98 break;
99 signal(SIGCHLD, osigchld); 99 signal(SIGCHLD, osigchld);