summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Hieber <r.hieber@pengutronix.de>2017-07-25 23:22:45 +0200
committerRoland Hieber <r.hieber@pengutronix.de>2017-07-25 23:30:59 +0200
commitb1a0745a6ccd479d4cf00e7c545e83453e536657 (patch)
tree5b7090cdd9565d36b57edc75ac840fee1e2eaf75
parentd65d9c2772736fab42235cf01909a1d0f90a05f1 (diff)
downloadurshd-b1a0745a6ccd479d4cf00e7c545e83453e536657.tar.gz
urshd-b1a0745a6ccd479d4cf00e7c545e83453e536657.tar.xz
urshd: fix error handling in write
The broken error handling had the effect that no command was ever executed on the target, with only a message "Unable to write: Success" in the syslog. Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
-rw-r--r--src/urshd.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/urshd.c b/src/urshd.c
index 5391774..c7c6dd2 100644
--- a/src/urshd.c
+++ b/src/urshd.c
@@ -189,7 +189,7 @@ error(const char *fmt, ...)
vsnprintf(bp, sizeof(buf) - 1, fmt, ap);
va_end(ap);
- if (write(2, buf, strlen(buf)) != 0) {
+ if (write(2, buf, strlen(buf)) < 0) {
fatal("error: write: %m");
}
}
@@ -265,7 +265,7 @@ stderr_parent(int sock, int pype, int pid)
FD_CLR(pype, &readfrom);
guys--;
} else {
- if (write(sock, buf, cc) != 0) {
+ if (write(sock, buf, cc) < 0) {
fatal("stderr_parent: %m");
}
}
@@ -342,7 +342,7 @@ doit(struct sockaddr_in6 *fromp)
exit(1);
}
- if (write(2, "\0", 1) != 0) {
+ if (write(2, "\0", 1) < 0) {
fatal("Unable to write: %m");
}
sent_null = 1;