Commit e90520eb authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Do not chain multiple getaddrinfo implementation.

This is bound to crash.
parent bf9fed9b
...@@ -566,12 +566,11 @@ int vlc_getnameinfo( const struct sockaddr *sa, int salen, ...@@ -566,12 +566,11 @@ int vlc_getnameinfo( const struct sockaddr *sa, int salen,
psz_serv = NULL; psz_serv = NULL;
i_servlen = 0; i_servlen = 0;
} }
#if defined( WIN32 ) && !defined( UNDER_CE )
i_val = ws2_getnameinfo( sa, salen, host, hostlen, psz_serv, #if defined (HAVE_GETNAMEINFO)
i_servlen, flags );
#endif
#if defined( HAVE_GETNAMEINFO ) || defined( UNDER_CE )
i_val = getnameinfo(sa, salen, host, hostlen, psz_serv, i_servlen, flags); i_val = getnameinfo(sa, salen, host, hostlen, psz_serv, i_servlen, flags);
#elif defined (WIN32)
i_val = ws2_getnameinfo (sa, salen, host, hostlen, psz_serv, i_servlen, flags);
#else #else
i_val = __getnameinfo (sa, salen, host, hostlen, psz_serv, i_servlen, flags); i_val = __getnameinfo (sa, salen, host, hostlen, psz_serv, i_servlen, flags);
#endif #endif
...@@ -655,7 +654,7 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node, ...@@ -655,7 +654,7 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
} }
} }
#if defined( WIN32 ) && !defined( UNDER_CE ) #ifdef WIN32
/* /*
* Winsock tries to resolve numerical IPv4 addresses as AAAA * Winsock tries to resolve numerical IPv4 addresses as AAAA
* and IPv6 addresses as A... There comes the work around. * and IPv6 addresses as A... There comes the work around.
...@@ -669,61 +668,50 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node, ...@@ -669,61 +668,50 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
hints.ai_flags &= ~AI_NUMERICHOST; hints.ai_flags &= ~AI_NUMERICHOST;
} }
return ws2_getaddrinfo (psz_node, psz_service, &hints, res);
#endif #endif
#if defined( HAVE_GETADDRINFO ) || defined( UNDER_CE ) #if defined (HAVE_GETADDRINFO)
# ifdef AI_IDN # ifdef AI_IDN
/* Run-time I18n Domain Names support */ /* Run-time I18n Domain Names support */
{ static vlc_bool_t b_idn = VLC_TRUE; /* beware of thread-safety */
static vlc_bool_t i_idn = VLC_TRUE; /* beware of thread-safety */
if( i_idn )
{
int i_ret;
hints.ai_flags |= AI_IDN; if (b_idn)
i_ret = getaddrinfo( psz_node, psz_service, &hints, res ); {
hints.ai_flags |= AI_IDN;
if( i_ret != EAI_BADFLAGS ) int ret = getaddrinfo (psz_node, psz_service, &hints, res);
return i_ret;
/* libidn not available: disable and retry without it */ if (ret != EAI_BADFLAGS)
return ret;
/* NOTE: Using i_idn here would not be thread-safe */ /* IDN not available: disable and retry without it */
hints.ai_flags &= ~AI_IDN; hints.ai_flags &= ~AI_IDN;
i_idn = VLC_FALSE; b_idn = VLC_FALSE;
msg_Dbg( p_this, "International Domain Names not supported - " \ msg_Info (p_this, "International Domain Names not supported");
"disabled" );
}
} }
# endif # endif
return getaddrinfo( psz_node, psz_service, &hints, res ); return getaddrinfo (psz_node, psz_service, &hints, res);
#elif defined (WIN32)
return ws2_getaddrinfo (psz_node, psz_service, &hints, res);
#else #else
{ int ret;
int i_ret;
vlc_value_t lock; vlc_value_t lock;
var_Create( p_this->p_libvlc, "getaddrinfo_mutex", VLC_VAR_MUTEX ); var_Create (p_this->p_libvlc, "getaddrinfo_mutex", VLC_VAR_MUTEX);
var_Get( p_this->p_libvlc, "getaddrinfo_mutex", &lock ); var_Get (p_this->p_libvlc, "getaddrinfo_mutex", &lock);
vlc_mutex_lock( lock.p_address ); vlc_mutex_lock (lock.p_address);
i_ret = __getaddrinfo( psz_node, psz_service, &hints, res ); int ret = __getaddrinfo (psz_node, psz_service, &hints, res);
vlc_mutex_unlock( lock.p_address ); vlc_mutex_unlock (lock.p_address);
return i_ret; return ret;
}
#endif #endif
} }
void vlc_freeaddrinfo( struct addrinfo *infos ) void vlc_freeaddrinfo( struct addrinfo *infos )
{ {
#if defined( WIN32 ) && !defined( UNDER_CE ) #if defined (HAVE_GETADDRINFO)
ws2_freeaddrinfo( infos ); freeaddrinfo (infos);
#endif #elif defined (WIN32)
#if defined( HAVE_GETADDRINFO ) || defined( UNDER_CE ) ws2_freeaddrinfo (infos);
freeaddrinfo( infos );
#else #else
__freeaddrinfo( infos ); __freeaddrinfo( infos );
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment