Changeset e41bccdf8818640a8a03241c1a36613995a779fc

Show
Ignore:
Timestamp:
05/28/08 17:49:50 (3 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1211989790 +0300
git-parent:

[eb43a637d79cef96542e0e7f2bf52f82fdebcaf4]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1211989785 +0300
Message:

Simplify, and remove racy IDN code

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/network/getaddrinfo.c

    r1f75e57 re41bccd  
    6161 
    6262#ifndef HAVE_GAI_STRERROR 
    63 static struct 
    64 { 
    65     int code; 
    66     const char *msg; 
    67 } const __gai_errlist[] = 
     63static const struct 
     64{ 
     65    char      code; 
     66    const char msg[41] 
     67} gai_errlist[] = 
    6868{ 
    6969    { 0,              "Error 0" }, 
     
    8383}; 
    8484 
    85 static const char __gai_unknownerr[] = "Unrecognized error number"; 
     85static const char gai_unknownerr[] = "Unrecognized error number"; 
    8686 
    8787/**************************************************************************** 
     
    9090const char *vlc_gai_strerror (int errnum) 
    9191{ 
    92     for (unsigned i = 0; __gai_errlist[i].msg != NULL; i++) 
    93         if (errnum == __gai_errlist[i].code) 
    94             return __gai_errlist[i].msg; 
    95  
    96     return __gai_unknownerr; 
     92    for (unsigned i = 0; gai_errlist[i].msg != NULL; i++) 
     93        if (errnum == gai_errlist[i].code) 
     94            return gai_errlist[i].msg; 
     95 
     96    return gai_unknownerr; 
    9797} 
    9898#else /* ifndef HAVE_GAI_STRERROR */ 
     
    623623    if( hints.ai_family == AF_UNSPEC ) 
    624624    { 
    625         vlc_value_t val; 
    626  
    627         var_Create( p_this, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 
    628         var_Get( p_this, "ipv4", &val ); 
    629         if( val.b_bool ) 
     625#ifdef AF_INET6 
     626        if (var_CreateGetBool (p_this, "ipv6")) 
     627            hints.ai_family = AF_INET6; 
     628        else 
     629#endif 
     630        if (var_CreateGetBool (p_this, "ipv4")) 
    630631            hints.ai_family = AF_INET; 
    631  
    632 #ifdef AF_INET6 
    633         var_Create( p_this, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 
    634         var_Get( p_this, "ipv6", &val ); 
    635         if( val.b_bool ) 
    636             hints.ai_family = AF_INET6; 
    637 #endif 
    638632    } 
    639633 
     
    684678# ifdef AI_IDN 
    685679    /* Run-time I18n Domain Names support */ 
    686     static bool b_idn = true; /* beware of thread-safety */ 
    687  
    688     if (b_idn) 
    689     { 
    690         hints.ai_flags |= AI_IDN; 
    691         int ret = getaddrinfo (psz_node, psz_service, &hints, res); 
    692  
    693         if (ret != EAI_BADFLAGS) 
    694             return ret; 
    695  
    696         /* IDN not available: disable and retry without it */ 
    697         hints.ai_flags &= ~AI_IDN; 
    698         b_idn = false; 
    699         msg_Info (p_this, "International Domain Names not supported"); 
    700     } 
     680    hints.ai_flags |= AI_IDN; 
     681    int ret = getaddrinfo (psz_node, psz_service, &hints, res); 
     682    if (ret != EAI_BADFLAGS) 
     683        return ret; 
     684 
     685    /* IDN not available: disable and retry without it */ 
     686    hints.ai_flags &= ~AI_IDN; 
    701687# endif 
    702688    return getaddrinfo (psz_node, psz_service, &hints, res);