Changeset e41bccdf8818640a8a03241c1a36613995a779fc
- 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
| r1f75e57 |
re41bccd |
|
| 61 | 61 | |
|---|
| 62 | 62 | #ifndef HAVE_GAI_STRERROR |
|---|
| 63 | | static struct |
|---|
| 64 | | { |
|---|
| 65 | | int code; |
|---|
| 66 | | const char *msg; |
|---|
| 67 | | } const __gai_errlist[] = |
|---|
| | 63 | static const struct |
|---|
| | 64 | { |
|---|
| | 65 | char code; |
|---|
| | 66 | const char msg[41] |
|---|
| | 67 | } gai_errlist[] = |
|---|
| 68 | 68 | { |
|---|
| 69 | 69 | { 0, "Error 0" }, |
|---|
| … | … | |
| 83 | 83 | }; |
|---|
| 84 | 84 | |
|---|
| 85 | | static const char __gai_unknownerr[] = "Unrecognized error number"; |
|---|
| | 85 | static const char gai_unknownerr[] = "Unrecognized error number"; |
|---|
| 86 | 86 | |
|---|
| 87 | 87 | /**************************************************************************** |
|---|
| … | … | |
| 90 | 90 | const char *vlc_gai_strerror (int errnum) |
|---|
| 91 | 91 | { |
|---|
| 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; |
|---|
| 97 | 97 | } |
|---|
| 98 | 98 | #else /* ifndef HAVE_GAI_STRERROR */ |
|---|
| … | … | |
| 623 | 623 | if( hints.ai_family == AF_UNSPEC ) |
|---|
| 624 | 624 | { |
|---|
| 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")) |
|---|
| 630 | 631 | 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 |
|---|
| 638 | 632 | } |
|---|
| 639 | 633 | |
|---|
| … | … | |
| 684 | 678 | # ifdef AI_IDN |
|---|
| 685 | 679 | /* 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; |
|---|
| 701 | 687 | # endif |
|---|
| 702 | 688 | return getaddrinfo (psz_node, psz_service, &hints, res); |
|---|