Add a somewhat redundant check on the len arguement to getsockaddr() to

avoid relying on the minimum memory allocation size to avoid problems.
The check is somewhat redundant because the consumers of the returned
structure will check that sa_len is a protocol-specific larger size.

Submitted by:	Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by:	nectar
MFC after:	30 days
This commit is contained in:
Don Lewis 2004-01-10 08:28:54 +00:00
parent 3f02eaf396
commit 2b77864f1e

View File

@ -1607,6 +1607,8 @@ getsockaddr(namp, uaddr, len)
if (len > SOCK_MAXADDRLEN)
return ENAMETOOLONG;
if (len < offsetof(struct sockaddr, sa_data[0]))
return EINVAL;
MALLOC(sa, struct sockaddr *, len, M_SONAME, M_WAITOK);
error = copyin(uaddr, sa, len);
if (error) {