From c89070fe7b65c3f3a8a5c693ce3298a9598d1c02 Mon Sep 17 00:00:00 2001 From: halex <> Date: Sun, 22 Mar 2015 22:32:03 +0000 Subject: 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@ --- src/lib/libc/net/rcmd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/lib') 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, char c, *p; int refused; in_port_t rport = porta; + int numread; /* call rcmdsh() with specified remote shell if appropriate. */ if (!issetugid() && (p = getenv("RSH")) && *p) { @@ -264,9 +265,10 @@ again: (void)write(s, locuser, strlen(locuser)+1); (void)write(s, remuser, strlen(remuser)+1); (void)write(s, cmd, strlen(cmd)+1); - if (read(s, &c, 1) != 1) { + if ((numread = read(s, &c, 1)) != 1) { (void)fprintf(stderr, - "rcmd: %s: %s\n", *ahost, strerror(errno)); + "rcmd: %s: %s\n", *ahost, + numread == -1 ? strerror(errno) : "Short read"); goto bad2; } if (c != 0) { -- cgit v1.2.3-55-g6feb