diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-01-18 10:07:01 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-01-18 10:07:01 +0000 |
commit | e76afb7be1dbbd9337901dee42569c495ffa32ba (patch) | |
tree | a5b3645a5dc03872d434111beccdcba4eec64eee /inet/rcmd.c | |
parent | d32e434671df2f3d1127ffeef7e6800b6226ceea (diff) | |
download | glibc-e76afb7be1dbbd9337901dee42569c495ffa32ba.tar glibc-e76afb7be1dbbd9337901dee42569c495ffa32ba.tar.gz glibc-e76afb7be1dbbd9337901dee42569c495ffa32ba.tar.bz2 glibc-e76afb7be1dbbd9337901dee42569c495ffa32ba.zip |
(rcmd_af): Protect socket operations with TEMP_FAILURE_RETRY. Use writev instead of multiple write.
Diffstat (limited to 'inet/rcmd.c')
-rw-r--r-- | inet/rcmd.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/inet/rcmd.c b/inet/rcmd.c index eed5ed389e..4737e6e315 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -83,6 +83,7 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; #ifdef USE_IN_LIBIO # include <wchar.h> #endif +#include <sys/uio.h> int __ivaliduser (FILE *, u_int32_t, const char *, const char *); @@ -323,7 +324,8 @@ poll: protocol failure in circuit setup\n")) >= 0)) (void)__close(s2); goto bad; } - s3 = accept(s2, (struct sockaddr *)&from, &len); + s3 = TEMP_FAILURE_RETRY (accept(s2, (struct sockaddr *)&from, + &len)); switch (from.ss_family) { case AF_INET: rport = ntohs(((struct sockaddr_in *)&from)->sin_port); @@ -367,10 +369,17 @@ socket: protocol failure in circuit setup\n")) >= 0) goto bad2; } } - (void)__write(s, locuser, strlen(locuser)+1); - (void)__write(s, remuser, strlen(remuser)+1); - (void)__write(s, cmd, strlen(cmd)+1); - n = __read(s, &c, 1); + struct iovec iov[3] = + { + [0] = { .iov_base = (void *) locuser, + .iov_len = strlen (locuser) + 1 }, + [1] = { .iov_base = (void *) remuser, + .iov_len = strlen (remuser) + 1 }, + [2] = { .iov_base = (void *) cmd, + .iov_len = strlen (cmd) + 1 } + }; + (void) TEMP_FAILURE_RETRY (__writev (s, iov, 3)); + n = TEMP_FAILURE_RETRY (__read(s, &c, 1)); if (n != 1) { char *buf = NULL; |