- Always use AI_NUMERICSERV since we cannot use service names in LibVLC
authorRémi Denis-Courmont <rem@videolan.org>
Mon, 12 Mar 2007 19:18:16 +0000 (19:18 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Mon, 12 Mar 2007 19:18:16 +0000 (19:18 +0000)
- Only pass used ai_flags so we won't break if broken IETF draft
  draft-chakrabarti-ipv6-addrselect-api-05 makes it to standard

src/network/getaddrinfo.c

index 70183d6..aa275eb 100644 (file)
@@ -589,10 +589,16 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
     snprintf( psz_service, 6, "%d", i_port );
 
     /* Check if we have to force ipv4 or ipv6 */
-    if( p_hints == NULL )
-        memset( &hints, 0, sizeof( hints ) );
-    else
-        memcpy( &hints, p_hints, sizeof( hints ) );
+    memset (&hints, 0, sizeof (hints));
+    if (p_hints != NULL)
+    {
+        hints.ai_family = p_hints->ai_family;
+        hints.ai_socktype = p_hints->ai_socktype;
+        hints.ai_protocol = p_hints->ai_protocol;
+        hints.ai_flags = p_hints->ai_flags & (AI_NUMERICHOST|AI_PASSIVE);
+    }
+    /* we only ever use port *numbers* */
+    hints.ai_flags |= AI_NUMERICSERV;
 
     if( hints.ai_family == AF_UNSPEC )
     {