From 308ea8eb3eed15a4b32593346d38c82cbf919f4f Mon Sep 17 00:00:00 2001 From: Sam Varshavchik Date: Thu, 5 Dec 2019 23:21:07 -0500 Subject: gnutls: UTF-8 and hostname fixes. --- rfc1035/rfc1035qa.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'rfc1035') diff --git a/rfc1035/rfc1035qa.c b/rfc1035/rfc1035qa.c index 46fc204..ffed34f 100644 --- a/rfc1035/rfc1035qa.c +++ b/rfc1035/rfc1035qa.c @@ -1,5 +1,5 @@ /* -** Copyright 1998 - 2011 Double Precision, Inc. +** Copyright 1998 - 2019 Double Precision, Inc. ** See COPYING for distribution information. */ @@ -8,6 +8,7 @@ #include #include #include +#include /* Convenient function to do forward IP lookup */ @@ -16,8 +17,9 @@ static int rfc1035_a_ipv4(struct rfc1035_res *res, const char *name, struct in_addr **iaptr, unsigned *iasize) #else -int rfc1035_a(struct rfc1035_res *res, - const char *name, RFC1035_ADDR **iaptr, unsigned *iasize) +static int rfc1035_unicode(struct rfc1035_res *res, + const char *name, + RFC1035_ADDR **iaptr, unsigned *iasize) #endif { struct rfc1035_reply *reply; @@ -111,8 +113,9 @@ unsigned i; return (0); } -int rfc1035_a(struct rfc1035_res *res, - const char *name, struct in6_addr **iaptr, unsigned *iasize) +static int rfc1035_unicode(struct rfc1035_res *res, + const char *name, struct in6_addr **iaptr, + unsigned *iasize) { struct rfc1035_reply *reply; int n, o; @@ -236,3 +239,21 @@ unsigned k; return (0); } #endif + +int rfc1035_a(struct rfc1035_res *res, + const char *name, + RFC1035_ADDR **iaptr, unsigned *iasize) +{ + char *p; + int r; + + /* Convert requested hostname to UTF-8, with fallback */ + + if (idna_to_unicode_8z8z(name, &p, 0) != IDNA_SUCCESS) + return rfc1035_unicode(res, name, iaptr, iasize); + + r=rfc1035_unicode(res, p, iaptr, iasize); + + free(p); + return r; +} -- cgit v1.2.3