diff options
| author | Sam Varshavchik | 2019-12-05 23:21:07 -0500 | 
|---|---|---|
| committer | Sam Varshavchik | 2019-12-05 23:21:07 -0500 | 
| commit | 308ea8eb3eed15a4b32593346d38c82cbf919f4f (patch) | |
| tree | 72382230f2d0efcfb501f0b53111ed50bfda2d64 /rfc1035/rfc1035qa.c | |
| parent | a16b12fc62d7deb1ac288eddf6ff826da69787f3 (diff) | |
| download | courier-libs-308ea8eb3eed15a4b32593346d38c82cbf919f4f.tar.bz2 | |
gnutls: UTF-8 and hostname fixes.
Diffstat (limited to 'rfc1035/rfc1035qa.c')
| -rw-r--r-- | rfc1035/rfc1035qa.c | 31 | 
1 files changed, 26 insertions, 5 deletions
| 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	<string.h>  #include	<stdlib.h>  #include	<arpa/inet.h> +#include	<idna.h>  /* 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; +} | 
