diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 396a71e84950..d94d9263f8ea 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -128,7 +128,7 @@ do_sa_get(struct sockaddr **sap, const struct osockaddr *osa, int *osalen, bdom = linux_to_bsd_domain(kosa->sa_family); if (bdom == -1) { - error = EINVAL; + error = EAFNOSUPPORT; goto out; } @@ -157,8 +157,13 @@ do_sa_get(struct sockaddr **sap, const struct osockaddr *osa, int *osalen, } } else #endif - if (bdom == AF_INET) + if (bdom == AF_INET) { alloclen = sizeof(struct sockaddr_in); + if (*osalen < alloclen) { + error = EINVAL; + goto out; + } + } sa = (struct sockaddr *) kosa; sa->sa_family = bdom;