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:
parent
3f02eaf396
commit
2b77864f1e
@ -1607,6 +1607,8 @@ getsockaddr(namp, uaddr, len)
|
|||||||
|
|
||||||
if (len > SOCK_MAXADDRLEN)
|
if (len > SOCK_MAXADDRLEN)
|
||||||
return ENAMETOOLONG;
|
return ENAMETOOLONG;
|
||||||
|
if (len < offsetof(struct sockaddr, sa_data[0]))
|
||||||
|
return EINVAL;
|
||||||
MALLOC(sa, struct sockaddr *, len, M_SONAME, M_WAITOK);
|
MALLOC(sa, struct sockaddr *, len, M_SONAME, M_WAITOK);
|
||||||
error = copyin(uaddr, sa, len);
|
error = copyin(uaddr, sa, len);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user