summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/rcmdsh.c
diff options
context:
space:
mode:
authorderaadt <>2019-06-28 13:35:02 +0000
committerderaadt <>2019-06-28 13:35:02 +0000
commit6585927e66d9ab172754d95c4296dd4309a40512 (patch)
treebc969c069c7b769f2601db17f08bec99274202a5 /src/lib/libc/net/rcmdsh.c
parent74ff76124ba7a371400a9f60d5e33192a3732f03 (diff)
downloadopenbsd-6585927e66d9ab172754d95c4296dd4309a40512.tar.gz
openbsd-6585927e66d9ab172754d95c4296dd4309a40512.tar.bz2
openbsd-6585927e66d9ab172754d95c4296dd4309a40512.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 'src/lib/libc/net/rcmdsh.c')
-rw-r--r--src/lib/libc/net/rcmdsh.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/libc/net/rcmdsh.c b/src/lib/libc/net/rcmdsh.c
index b9cbd6d5d1..66caac3f3d 100644
--- a/src/lib/libc/net/rcmdsh.c
+++ b/src/lib/libc/net/rcmdsh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rcmdsh.c,v 1.19 2016/05/28 15:46:00 millert Exp $ */ 1/* $OpenBSD: rcmdsh.c,v 1.20 2019/06/28 13:32:42 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, MagniComp 4 * Copyright (c) 2001, MagniComp
@@ -89,13 +89,13 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser,
89 } 89 }
90 90
91 /* Get a socketpair we'll use for stdin and stdout. */ 91 /* Get a socketpair we'll use for stdin and stdout. */
92 if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) < 0) { 92 if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) == -1) {
93 perror("rcmdsh: socketpair"); 93 perror("rcmdsh: socketpair");
94 return(-1); 94 return(-1);
95 } 95 }
96 96
97 cpid = fork(); 97 cpid = fork();
98 if (cpid < 0) { 98 if (cpid == -1) {
99 perror("rcmdsh: fork failed"); 99 perror("rcmdsh: fork failed");
100 return(-1); 100 return(-1);
101 } else if (cpid == 0) { 101 } else if (cpid == 0) {
@@ -103,13 +103,13 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser,
103 * Child. We use sp[1] to be stdin/stdout, and close sp[0]. 103 * Child. We use sp[1] to be stdin/stdout, and close sp[0].
104 */ 104 */
105 (void) close(sp[0]); 105 (void) close(sp[0]);
106 if (dup2(sp[1], 0) < 0 || dup2(0, 1) < 0) { 106 if (dup2(sp[1], 0) == -1 || dup2(0, 1) == -1) {
107 perror("rcmdsh: dup2 failed"); 107 perror("rcmdsh: dup2 failed");
108 _exit(255); 108 _exit(255);
109 } 109 }
110 /* Fork again to lose parent. */ 110 /* Fork again to lose parent. */
111 cpid = fork(); 111 cpid = fork();
112 if (cpid < 0) { 112 if (cpid == -1) {
113 perror("rcmdsh: fork to lose parent failed"); 113 perror("rcmdsh: fork to lose parent failed");
114 _exit(255); 114 _exit(255);
115 } 115 }