The SA-16:19 wouldn't have happened if the sockargs() had properly typed

argument for length.  While here make it static and convert to ANSI C.

Reviewed by:	C Turt
This commit is contained in:
Gleb Smirnoff 2016-05-18 22:05:50 +00:00
parent 9aa8749970
commit e987742995
2 changed files with 4 additions and 10 deletions

View File

@ -84,6 +84,7 @@ static int getsockname1(struct thread *td, struct getsockname_args *uap,
int compat); int compat);
static int getpeername1(struct thread *td, struct getpeername_args *uap, static int getpeername1(struct thread *td, struct getpeername_args *uap,
int compat); int compat);
static int sockargs(struct mbuf **, char *, socklen_t, int);
/* /*
* Convert a user file descriptor to a kernel file entry and check if required * Convert a user file descriptor to a kernel file entry and check if required
@ -1689,19 +1690,13 @@ ogetpeername(td, uap)
} }
#endif /* COMPAT_OLDSOCK */ #endif /* COMPAT_OLDSOCK */
int static int
sockargs(mp, buf, buflen, type) sockargs(struct mbuf **mp, char *buf, socklen_t buflen, int type)
struct mbuf **mp;
caddr_t buf;
int buflen, type;
{ {
struct sockaddr *sa; struct sockaddr *sa;
struct mbuf *m; struct mbuf *m;
int error; int error;
if (buflen < 0)
return (EINVAL);
if (buflen > MLEN) { if (buflen > MLEN) {
#ifdef COMPAT_OLDSOCK #ifdef COMPAT_OLDSOCK
if (type == MT_SONAME && buflen <= 112) if (type == MT_SONAME && buflen <= 112)
@ -1713,7 +1708,7 @@ sockargs(mp, buf, buflen, type)
} }
m = m_get2(buflen, M_WAITOK, type, 0); m = m_get2(buflen, M_WAITOK, type, 0);
m->m_len = buflen; m->m_len = buflen;
error = copyin(buf, mtod(m, caddr_t), (u_int)buflen); error = copyin(buf, mtod(m, void *), buflen);
if (error != 0) if (error != 0)
(void) m_free(m); (void) m_free(m);
else { else {

View File

@ -335,7 +335,6 @@ struct uio;
/* /*
* From uipc_socket and friends * From uipc_socket and friends
*/ */
int sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type);
int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len); int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len);
int getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp, int getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp,
struct file **fpp, u_int *fflagp); struct file **fpp, u_int *fflagp);