*slp = NULL;
- if (uaddr == USER_ADDR_NULL || uaddrlen == 0)
+ if (uaddr == USER_ADDR_NULL || uaddrlen == 0 ||
+ uaddrlen > (sizeof(struct sockaddr_in6) * SOCKADDRLIST_MAX_ENTRIES))
return (EINVAL);
sl = sockaddrlist_alloc(M_WAITOK);
} else if (ss.ss_len > sizeof (ss)) {
/*
* sockaddr_storage size is less than SOCK_MAXADDRLEN,
- * so the check here is inclusive. We could user the
+ * so the check here is inclusive. We could use the
* latter instead, but seems like an overkill for now.
*/
error = ENAMETOOLONG;
}
se = sockaddrentry_alloc(M_WAITOK);
- if (se == NULL)
+ if (se == NULL) {
+ error = ENOBUFS;
break;
+ }
sockaddrlist_insert(sl, se);