summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt>2019-06-28 13:35:05 +0000
committerderaadt <deraadt>2019-06-28 13:35:05 +0000
commit4ff7bc3eb32e9d66312d16757fb8c083df2d87d6 (patch)
treeb505bffb084d50d6487010fbeb03c55936a998ca
parent6ce38b73956836c26c8914cdf5002da7900a5d2d (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.
-rw-r--r--client.c2
-rw-r--r--job.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/client.c b/client.c
index b376b038..d071b1db 100644
--- a/client.c
+++ b/client.c
@@ -434,7 +434,7 @@ client_stdin_callback(__unused int fd, __unused short events,
struct msg_stdin_data data;
data.size = read(STDIN_FILENO, data.data, sizeof data.data);
- if (data.size < 0 && (errno == EINTR || errno == EAGAIN))
+ if (data.size == -1 && (errno == EINTR || errno == EAGAIN))
return;
proc_send(client_peer, MSG_STDIN, -1, &data, sizeof data);
diff --git a/job.c b/job.c
index 73f62359..0c316fd8 100644
--- a/job.c
+++ b/job.c
@@ -118,7 +118,7 @@ job_run(const char *cmd, struct session *s, const char *cwd,
close(out[0]);
nullfd = open(_PATH_DEVNULL, O_RDWR, 0);
- if (nullfd < 0)
+ if (nullfd == -1)
fatal("open failed");
if (dup2(nullfd, STDERR_FILENO) == -1)
fatal("dup2 failed");