diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/posix/getaddrinfo.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index afdefdfb52..2b6f0ba0ac 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -55,6 +55,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <nsswitch.h> #include <not-cancel.h> +extern int __idna_to_ascii_lz (const char *input, char **output, int flags); +#define IDNA_SUCCESS 0 + #define GAIH_OKIFUNSPEC 0x0100 #define GAIH_EAI ~(GAIH_OKIFUNSPEC) @@ -539,6 +542,18 @@ gaih_inet (const char *name, const struct gaih_service *service, at->scopeid = 0; at->next = NULL; +#ifdef HAVE_LIBIDN + if (req->ai_flags & AI_IDN) + { + char *p = NULL; + rc = __idna_to_ascii_lz (name, &p, 0); + if (rc != IDNA_SUCCESS) + return -EAI_IDN_ENCODE; + name = strdupa (p); + free (p); + } +#endif + if (inet_pton (AF_INET, name, at->addr) > 0) { if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET) @@ -1252,6 +1267,9 @@ getaddrinfo (const char *name, const char *service, if (hints->ai_flags & ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST|AI_ADDRCONFIG|AI_V4MAPPED +#ifdef HAVE_LIBIDN + |AI_IDN +#endif |AI_ALL)) return EAI_BADFLAGS; |