summaryrefslogtreecommitdiffstats
path: root/rfc1035/rfc1035reply.c
diff options
context:
space:
mode:
authorSam Varshavchik2018-07-23 21:14:02 -0400
committerSam Varshavchik2018-07-23 21:14:02 -0400
commita925caf69bd414999369b855fe47a39e8e41affb (patch)
tree9466eea4ffd7780e744770c79d6e1308cd87bfe5 /rfc1035/rfc1035reply.c
parent14179a773e02455620b8db480e5cde990301bdb1 (diff)
downloadcourier-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.c22
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:"");
}