svn commit: r300431 - head/sys/compat/linux
Dmitry Chagin
dchagin at FreeBSD.org
Sun May 22 19:08:30 UTC 2016
Author: dchagin
Date: Sun May 22 19:08:29 2016
New Revision: 300431
URL: https://svnweb.freebsd.org/changeset/base/300431
Log:
Convert proto family in both directions. The linux and native values for
local and inet are identical, but for inet6 values differ.
PR: 155040
Reported by: Simon Walton
MFC after: 2 week
Modified:
head/sys/compat/linux/linux_socket.c
Modified: head/sys/compat/linux/linux_socket.c
==============================================================================
--- head/sys/compat/linux/linux_socket.c Sun May 22 19:06:38 2016 (r300430)
+++ head/sys/compat/linux/linux_socket.c Sun May 22 19:08:29 2016 (r300431)
@@ -462,12 +462,16 @@ bsd_to_linux_sockaddr(struct sockaddr *a
{
struct sockaddr sa;
size_t sa_len = sizeof(struct sockaddr);
- int error;
+ int error, bdom;
if ((error = copyin(arg, &sa, sa_len)))
return (error);
- *(u_short *)&sa = sa.sa_family;
+ bdom = bsd_to_linux_domain(sa.sa_family);
+ if (bdom == -1)
+ return (EAFNOSUPPORT);
+
+ *(u_short *)&sa = bdom;
return (copyout(&sa, arg, sa_len));
}
@@ -476,12 +480,16 @@ linux_to_bsd_sockaddr(struct sockaddr *a
{
struct sockaddr sa;
size_t sa_len = sizeof(struct sockaddr);
- int error;
+ int error, bdom;
if ((error = copyin(arg, &sa, sa_len)))
return (error);
- sa.sa_family = *(sa_family_t *)&sa;
+ bdom = linux_to_bsd_domain(*(sa_family_t *)&sa);
+ if (bdom == -1)
+ return (EAFNOSUPPORT);
+
+ sa.sa_family = bdom;
sa.sa_len = len;
return (copyout(&sa, arg, sa_len));
}
More information about the svn-src-all
mailing list