summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoritojun <itojun@openbsd.org>2002-05-24 09:15:29 +0000
committeritojun <itojun@openbsd.org>2002-05-24 09:15:29 +0000
commita89bef5bc05152644e797823d1eb2b7a04ffeeeb (patch)
tree2cba1f5d4ebd125cc891c1adb1113b80227240f4
parentProtect biodone with splbio. (diff)
downloadwireguard-openbsd-a89bef5bc05152644e797823d1eb2b7a04ffeeeb.tar.xz
wireguard-openbsd-a89bef5bc05152644e797823d1eb2b7a04ffeeeb.zip
make a strict check before sending FQDN node information reply. sync w/kame
-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++;