summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2009-11-19 22:07:18 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2009-11-19 22:07:18 +0000
commit6279f0e454c58952697eaaef20230dac555d0988 (patch)
tree91886ea5f42cf723ecce57ca97d56e70cee67d02 /sys
parent9154d3a5e501d11a25757edfab551cba7c777b33 (diff)
avoid overflow since protos > IPPROTO_MAX exist. From FreeBSD with
a twist; ok millert@ kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/ip_input.c5
-rw-r--r--sys/netinet6/ip6_input.c5
2 files changed, 6 insertions, 4 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index c481333d176..fab61db1594 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.172 2009/11/03 10:59:04 claudio Exp $ */
+/* $OpenBSD: ip_input.c,v 1.173 2009/11/19 22:07:17 otto Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -199,7 +199,8 @@ ip_init()
for (pr = inetdomain.dom_protosw;
pr < inetdomain.dom_protoswNPROTOSW; pr++)
if (pr->pr_domain->dom_family == PF_INET &&
- pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
+ pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW &&
+ pr->pr_protocol < IPPROTO_MAX)
ip_protox[pr->pr_protocol] = pr - inetsw;
LIST_INIT(&ipq);
ipintrq.ifq_maxlen = ipqmaxlen;
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index c1c778df180..40e739c57ea 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_input.c,v 1.92 2009/11/03 10:59:04 claudio Exp $ */
+/* $OpenBSD: ip6_input.c,v 1.93 2009/11/19 22:07:17 otto Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -157,7 +157,8 @@ ip6_init()
for (pr = (struct ip6protosw *)inet6domain.dom_protosw;
pr < (struct ip6protosw *)inet6domain.dom_protoswNPROTOSW; pr++)
if (pr->pr_domain->dom_family == PF_INET6 &&
- pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
+ pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW &&
+ pr->pr_protocol < IPPROTO_MAX)
ip6_protox[pr->pr_protocol] = pr - inet6sw;
ip6intrq.ifq_maxlen = ip6qmaxlen;
ip6_randomid_init();