Merge pull request #654 from alesliehughes/master
[mono.git] / mono / metadata / socket-io.c
index 59a3b619ab226865ec3312a259d81f298cc7063c..60cb7a527e474b06bef5b358721ec83d7b8d5e8c 100644 (file)
@@ -930,20 +930,11 @@ static MonoObject *create_object_from_sockaddr(struct sockaddr *saddr,
                g_assert (domain->sockaddr_data_field);
        }
 
-       /* Make sure there is space for the family and size bytes */
-#ifdef HAVE_SYS_UN_H
-       if (saddr->sa_family == AF_UNIX) {
-               /* sa_len includes the entire sockaddr size, so we don't need the
-                * N bytes (sizeof (unsigned short)) of the family. */
-               data=mono_array_new_cached(domain, mono_get_byte_class (), sa_size);
-       } else
-#endif
-       {
-               /* May be the +2 here is too conservative, as sa_len returns
-                * the length of the entire sockaddr_in/in6, including
-                * sizeof (unsigned short) of the family */
-               data=mono_array_new_cached(domain, mono_get_byte_class (), sa_size+2);
-       }
+       /* May be the +2 here is too conservative, as sa_len returns
+        * the length of the entire sockaddr_in/in6, including
+        * sizeof (unsigned short) of the family */
+       /* We can't really avoid the +2 as all code below depends on this size - INCLUDING unix domain sockets.*/
+       data=mono_array_new_cached(domain, mono_get_byte_class (), sa_size+2);
 
        /* The data buffer is laid out as follows:
         * bytes 0 and 1 are the address family
@@ -2054,6 +2045,8 @@ static struct in6_addr ipaddress_to_struct_in6_addr(MonoObject *ipaddr)
 #endif /* AF_INET6 */
 #endif
 
+#if defined(__APPLE__)
+
 #if defined(HAVE_GETIFADDRS) && defined(HAVE_IF_NAMETOINDEX)
 static int
 get_local_interface_id (int family)
@@ -2090,6 +2083,8 @@ get_local_interface_id (int family)
 }
 #endif
 
+#endif /* __APPLE__ */
+
 void ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal(SOCKET sock, gint32 level, gint32 name, MonoObject *obj_val, MonoArray *byte_val, gint32 int_val, gint32 *error)
 {
        struct linger linger;