diff options
| author | Sam Varshavchik | 2018-07-23 21:14:02 -0400 | 
|---|---|---|
| committer | Sam Varshavchik | 2018-07-23 21:14:02 -0400 | 
| commit | a925caf69bd414999369b855fe47a39e8e41affb (patch) | |
| tree | 9466eea4ffd7780e744770c79d6e1308cd87bfe5 /rfc1035/rfc1035reply.c | |
| parent | 14179a773e02455620b8db480e5cde990301bdb1 (diff) | |
| download | courier-libs-a925caf69bd414999369b855fe47a39e8e41affb.tar.bz2 | |
librfc1035: use UTF8 for DNS queries
DNS lookups use libidn to convert UTF8 hostname to ACE.
DNS replies convert ACE to UTF8 hostnames.
Diffstat (limited to 'rfc1035/rfc1035reply.c')
| -rw-r--r-- | rfc1035/rfc1035reply.c | 22 | 
1 files changed, 19 insertions, 3 deletions
| diff --git a/rfc1035/rfc1035reply.c b/rfc1035/rfc1035reply.c index 98c3766..ac1e87e 100644 --- a/rfc1035/rfc1035reply.c +++ b/rfc1035/rfc1035reply.c @@ -1,5 +1,5 @@  /* -** Copyright 1998 - 1999 Double Precision, Inc. +** Copyright 1998 - 2018 Double Precision, Inc.  ** See COPYING for distribution information.  */ @@ -7,7 +7,7 @@  #include	<stdlib.h>  #include	<string.h>  #include	<errno.h> - +#include	<idna.h>  void rfc1035_replyfree(struct rfc1035_reply *p)  { @@ -71,7 +71,23 @@ int	cnt=0;  		*ptr += l;  	} -	if (namebuf)	namebuf[i]=0; +	if (namebuf) +	{ +		char *p; + +		namebuf[i]=0; + +		if (idna_to_unicode_8z8z(namebuf, &p, 0) != IDNA_SUCCESS) +			return (0); + +		if (strlen(p) >= RFC1035_MAXNAMESIZE) +		{ +			free(p); +			return (0); +		} +		strcpy(namebuf, p); +		free(p); +	}  	return (namebuf ? namebuf:"");  } | 
