summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2004-01-10 08:28:54 +0000
committertruckman <truckman@FreeBSD.org>2004-01-10 08:28:54 +0000
commit417693c81357ae1110479329847a2066e672e252 (patch)
treeab13aca7e5944882a297f51b6b461a08518551b0
parent12dea7eecf9f3819c08c18ddb59322a965f59512 (diff)
downloadFreeBSD-src-417693c81357ae1110479329847a2066e672e252.zip
FreeBSD-src-417693c81357ae1110479329847a2066e672e252.tar.gz
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
-rw-r--r--sys/kern/uipc_syscalls.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index b5c500a..2b6599c 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -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) {
OpenPOWER on IntegriCloud