diff options
author | 2015-03-22 22:32:03 +0000 | |
---|---|---|
committer | 2015-03-22 22:32:03 +0000 | |
commit | e12686f24eee65d490603988be24fdd2817291f6 (patch) | |
tree | c0ae753b2e83604a88d4080db60131f5c33e3097 /lib/libc | |
parent | Resolve a mandoc -Tlint warning about trailing whitespace. (diff) | |
download | wireguard-openbsd-e12686f24eee65d490603988be24fdd2817291f6.tar.xz wireguard-openbsd-e12686f24eee65d490603988be24fdd2817291f6.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@
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/net/rcmd.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index d10410b25a2..5ef44040019 100644 --- a/lib/libc/net/rcmd.c +++ b/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) { |