ref: 347303b136c41ac5ca4408818fdd1a3fde89888a
parent: 2160da07de7fcce233e2229318caa6f4f98f4a45
author: cinap_lenrek <[email protected]>
date: Tue Sep 25 16:17:56 EDT 2018
ip/dhcpd: handle internationalized domain names
--- a/sys/src/cmd/ip/dhcpd/dhcpd.c
+++ b/sys/src/cmd/ip/dhcpd/dhcpd.c
@@ -1584,7 +1584,7 @@
void
dnsnamesopt(Req *rp, int t, char *attr, Ndbtuple *nt)
{
- char *s;
+ char val[Maxstr], *s;
uchar *d;
int n, l;
@@ -1591,8 +1591,10 @@
for(; nt != nil; nt = nt->entry){
if(strcmp(nt->attr, attr) != 0)
continue;
+ if(utf2idn(nt->val, val, sizeof(val)) == nil)
+ continue;
d = &rp->p[2];
- for(s = nt->val; *s != 0; s++){
+ for(s = val; *s != 0; s++){
for(l = 0; *s != 0 && *s != '.'; l++)
s++;
if(l > 077)
@@ -1602,6 +1604,8 @@
return;
d[-l-1] = l;
memmove(d-l, s-l, l);
+ if(*s != '.')
+ break;
}
*d++ = 0;
n = d - &rp->p[2];
@@ -1610,7 +1614,7 @@
rp->p[0] = t;
rp->p[1] = n;
rp->p = d;
- op = seprint(op, oe, "%s(%s)", optname[t], nt->val);
+ op = seprint(op, oe, "%s(%s)", optname[t], val);
Skip:;
}
}
--- a/sys/src/cmd/ip/dhcpd/ndb.c
+++ b/sys/src/cmd/ip/dhcpd/ndb.c
@@ -305,7 +305,8 @@
for(nt = t; nt != nil; nt = nt->entry)
if(strcmp(nt->attr, "dom") == 0){
- strncpy(val, nt->val, len-1);
+ if(utf2idn(nt->val, val, len) == nil)
+ strncpy(val, nt->val, len-1);
val[len-1] = 0;
break;
}