Forgot to patch this file in file descriptor race fix commit

Submitted-by: "Danny J. Zerkel" <dzerkel@columbus.rr.com>
This commit is contained in:
Matthew Dillon 2000-11-23 11:05:14 +00:00
parent 700f2ee5c3
commit e0be78f6dc

View File

@ -162,7 +162,7 @@ svr4_sendit(p, s, mp, flags)
struct uio ktruio;
#endif
error = getsock(p->p_fd, s, &fp);
error = holdsock(p->p_fd, s, &fp);
if (error)
return (error);
auio.uio_iov = mp->msg_iov;
@ -174,15 +174,20 @@ svr4_sendit(p, s, mp, flags)
auio.uio_resid = 0;
iov = mp->msg_iov;
for (i = 0; i < mp->msg_iovlen; i++, iov++) {
if ((auio.uio_resid += iov->iov_len) < 0)
if ((auio.uio_resid += iov->iov_len) < 0) {
fdrop(fp, p);
return (EINVAL);
}
}
if (mp->msg_name) {
error = getsockaddr(&to, mp->msg_name, mp->msg_namelen);
if (error)
if (error) {
fdrop(fp, p);
return (error);
} else
}
} else {
to = 0;
}
if (mp->msg_control) {
if (mp->msg_controllen < sizeof(struct cmsghdr)) {
error = EINVAL;
@ -192,8 +197,9 @@ svr4_sendit(p, s, mp, flags)
mp->msg_controllen, MT_CONTROL);
if (error)
goto bad;
} else
} else {
control = 0;
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO)) {
int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
@ -229,6 +235,7 @@ svr4_sendit(p, s, mp, flags)
bad:
if (to)
FREE(to, M_SONAME);
fdrop(fp, p);
return (error);
}
@ -253,7 +260,7 @@ svr4_recvit(p, s, mp, namelenp)
struct uio ktruio;
#endif
error = getsock(p->p_fd, s, &fp);
error = holdsock(p->p_fd, s, &fp);
if (error)
return (error);
auio.uio_iov = mp->msg_iov;
@ -265,8 +272,10 @@ svr4_recvit(p, s, mp, namelenp)
auio.uio_resid = 0;
iov = mp->msg_iov;
for (i = 0; i < mp->msg_iovlen; i++, iov++) {
if ((auio.uio_resid += iov->iov_len) < 0)
if ((auio.uio_resid += iov->iov_len) < 0) {
fdrop(fp, p);
return (EINVAL);
}
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO)) {
@ -352,6 +361,7 @@ svr4_recvit(p, s, mp, namelenp)
FREE(fromsa, M_SONAME);
if (control)
m_freem(control);
fdrop(fp, p);
return (error);
}