summaryrefslogtreecommitdiff
path: root/lib/libc/net/rcmdsh.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2019-06-28 13:32:54 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2019-06-28 13:32:54 +0000
commit86ffccf24f66032a89d70a32b3609584c0db7345 (patch)
tree2ae97fac6ea5be57cc953baf8612e8f683da0172 /lib/libc/net/rcmdsh.c
parentce9fea47562d4f179d45680d6aec00ede2877141 (diff)
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 'lib/libc/net/rcmdsh.c')
-rw-r--r--lib/libc/net/rcmdsh.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libc/net/rcmdsh.c b/lib/libc/net/rcmdsh.c
index b9cbd6d5d14..66caac3f3d9 100644
--- a/lib/libc/net/rcmdsh.c
+++ b/lib/libc/net/rcmdsh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcmdsh.c,v 1.19 2016/05/28 15:46:00 millert Exp $ */
+/* $OpenBSD: rcmdsh.c,v 1.20 2019/06/28 13:32:42 deraadt Exp $ */
/*
* Copyright (c) 2001, MagniComp
@@ -89,13 +89,13 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser,
}
/* Get a socketpair we'll use for stdin and stdout. */
- if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) < 0) {
+ if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) == -1) {
perror("rcmdsh: socketpair");
return(-1);
}
cpid = fork();
- if (cpid < 0) {
+ if (cpid == -1) {
perror("rcmdsh: fork failed");
return(-1);
} else if (cpid == 0) {
@@ -103,13 +103,13 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser,
* Child. We use sp[1] to be stdin/stdout, and close sp[0].
*/
(void) close(sp[0]);
- if (dup2(sp[1], 0) < 0 || dup2(0, 1) < 0) {
+ if (dup2(sp[1], 0) == -1 || dup2(0, 1) == -1) {
perror("rcmdsh: dup2 failed");
_exit(255);
}
/* Fork again to lose parent. */
cpid = fork();
- if (cpid < 0) {
+ if (cpid == -1) {
perror("rcmdsh: fork to lose parent failed");
_exit(255);
}