summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-05-24 09:15:30 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-05-24 09:15:30 +0000
commit677d01e2583197003d44e3f93b034bbdec27d2ed (patch)
treee686b26a20082c3f91ea848448e247a2ed615dc5 /sys
parent7e339402117f656091c42a6cbc33d6bf6f8990f2 (diff)
make a strict check before sending FQDN node information reply. sync w/kame
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet6/icmp6.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index 2b98dde2706..df4bf9f2574 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icmp6.c,v 1.54 2002/03/14 01:27:11 millert Exp $ */
+/* $OpenBSD: icmp6.c,v 1.55 2002/05/24 09:15:29 itojun Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -1537,6 +1537,11 @@ ni6_input(m, off)
}
#undef hostnamelen
+#define isupper(x) ('A' <= (x) && (x) <= 'Z')
+#define isalpha(x) (('A' <= (x) && (x) <= 'Z') || ('a' <= (x) && (x) <= 'z'))
+#define isalnum(x) (isalpha(x) || ('0' <= (x) && (x) <= '9'))
+#define tolower(x) (isupper(x) ? (x) + 'a' - 'A' : (x))
+
/*
* make a mbuf with DNS-encoded string. no compression support.
*
@@ -1614,8 +1619,17 @@ ni6_nametodns(name, namelen, old)
if (i <= 0 || i >= 64)
goto fail;
*cp++ = i;
- bcopy(p, cp, i);
- cp += i;
+ if (!isalpha(p[0]) || !isalnum(p[i - 1]))
+ goto fail;
+ while (i > 0) {
+ if (!isalnum(*p) && *p != '-')
+ goto fail;
+ if (isupper(*p))
+ *cp++ = tolower(*p++);
+ else
+ *cp++ = *p++;
+ i--;
+ }
p = q;
if (p < name + namelen && *p == '.')
p++;