about summary refs log tree commit diff
path: root/inet
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-01-18 10:07:01 +0000
committerUlrich Drepper <drepper@redhat.com>2003-01-18 10:07:01 +0000
commite76afb7be1dbbd9337901dee42569c495ffa32ba (patch)
treea5b3645a5dc03872d434111beccdcba4eec64eee /inet
parentd32e434671df2f3d1127ffeef7e6800b6226ceea (diff)
downloadglibc-e76afb7be1dbbd9337901dee42569c495ffa32ba.tar.gz
glibc-e76afb7be1dbbd9337901dee42569c495ffa32ba.tar.xz
glibc-e76afb7be1dbbd9337901dee42569c495ffa32ba.zip
(rcmd_af): Protect socket operations with TEMP_FAILURE_RETRY. Use writev instead of multiple write.
Diffstat (limited to 'inet')
-rw-r--r--inet/rcmd.c19
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;