Author: dchagin
Date: Sun Jun  5 07:43:20 2016
New Revision: 301431
URL: https://svnweb.freebsd.org/changeset/base/301431

Log:
  MFC r300431:
  
  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

Modified:
  stable/10/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/compat/linux/linux_socket.c
==============================================================================
--- stable/10/sys/compat/linux/linux_socket.c   Sun Jun  5 07:40:12 2016        
(r301430)
+++ stable/10/sys/compat/linux/linux_socket.c   Sun Jun  5 07:43:20 2016        
(r301431)
@@ -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));
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to