summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhalex <>2015-03-22 22:32:03 +0000
committerhalex <>2015-03-22 22:32:03 +0000
commitc89070fe7b65c3f3a8a5c693ce3298a9598d1c02 (patch)
tree2b4bd16eea1f4ceb5c2f56f495cf05e0e96227dd
parent079b2af2236fbfabba4c0991950439ac5ff395ac (diff)
downloadopenbsd-c89070fe7b65c3f3a8a5c693ce3298a9598d1c02.tar.gz
openbsd-c89070fe7b65c3f3a8a5c693ce3298a9598d1c02.tar.bz2
openbsd-c89070fe7b65c3f3a8a5c693ce3298a9598d1c02.zip
differentiate between a failed read, returning -1, and encountering
end-of-file, returning 0, in order not to print an unrelated strerror(errno) in the latter case ok millert@
-rw-r--r--src/lib/libc/net/rcmd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/libc/net/rcmd.c b/src/lib/libc/net/rcmd.c
index d10410b25a..5ef4404001 100644
--- a/src/lib/libc/net/rcmd.c
+++ b/src/lib/libc/net/rcmd.c
@@ -70,6 +70,7 @@ rcmd_af(char **ahost, int porta, const char *locuser, const char *remuser,
70 char c, *p; 70 char c, *p;
71 int refused; 71 int refused;
72 in_port_t rport = porta; 72 in_port_t rport = porta;
73 int numread;
73 74
74 /* call rcmdsh() with specified remote shell if appropriate. */ 75 /* call rcmdsh() with specified remote shell if appropriate. */
75 if (!issetugid() && (p = getenv("RSH")) && *p) { 76 if (!issetugid() && (p = getenv("RSH")) && *p) {
@@ -264,9 +265,10 @@ again:
264 (void)write(s, locuser, strlen(locuser)+1); 265 (void)write(s, locuser, strlen(locuser)+1);
265 (void)write(s, remuser, strlen(remuser)+1); 266 (void)write(s, remuser, strlen(remuser)+1);
266 (void)write(s, cmd, strlen(cmd)+1); 267 (void)write(s, cmd, strlen(cmd)+1);
267 if (read(s, &c, 1) != 1) { 268 if ((numread = read(s, &c, 1)) != 1) {
268 (void)fprintf(stderr, 269 (void)fprintf(stderr,
269 "rcmd: %s: %s\n", *ahost, strerror(errno)); 270 "rcmd: %s: %s\n", *ahost,
271 numread == -1 ? strerror(errno) : "Short read");
270 goto bad2; 272 goto bad2;
271 } 273 }
272 if (c != 0) { 274 if (c != 0) {