(rcmd_af): Protect socket operations with TEMP_FAILURE_RETRY. Use writev instead of multiple write.
This commit is contained in:
parent
d32e434671
commit
e76afb7be1
19
inet/rcmd.c
19
inet/rcmd.c
|
@ -83,6 +83,7 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
|
||||||
#ifdef USE_IN_LIBIO
|
#ifdef USE_IN_LIBIO
|
||||||
# include <wchar.h>
|
# include <wchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <sys/uio.h>
|
||||||
|
|
||||||
|
|
||||||
int __ivaliduser (FILE *, u_int32_t, const char *, const char *);
|
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);
|
(void)__close(s2);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
s3 = accept(s2, (struct sockaddr *)&from, &len);
|
s3 = TEMP_FAILURE_RETRY (accept(s2, (struct sockaddr *)&from,
|
||||||
|
&len));
|
||||||
switch (from.ss_family) {
|
switch (from.ss_family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
rport = ntohs(((struct sockaddr_in *)&from)->sin_port);
|
rport = ntohs(((struct sockaddr_in *)&from)->sin_port);
|
||||||
|
@ -367,10 +369,17 @@ socket: protocol failure in circuit setup\n")) >= 0)
|
||||||
goto bad2;
|
goto bad2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void)__write(s, locuser, strlen(locuser)+1);
|
struct iovec iov[3] =
|
||||||
(void)__write(s, remuser, strlen(remuser)+1);
|
{
|
||||||
(void)__write(s, cmd, strlen(cmd)+1);
|
[0] = { .iov_base = (void *) locuser,
|
||||||
n = __read(s, &c, 1);
|
.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) {
|
if (n != 1) {
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue