summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/ip6_input.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2004-10-19 14:26:44 +0000
committerandre <andre@FreeBSD.org>2004-10-19 14:26:44 +0000
commit41dc9ace7562e46b5aef6d70ec7030dba3a2b361 (patch)
tree45142ca58e0f2d90b1e0cf97bd2736c3b56c8076 /sys/netinet6/ip6_input.c
parentf14caa383fa811b44b7a65d4e0973401823278f7 (diff)
downloadFreeBSD-src-41dc9ace7562e46b5aef6d70ec7030dba3a2b361.zip
FreeBSD-src-41dc9ace7562e46b5aef6d70ec7030dba3a2b361.tar.gz
Be more careful to only index valid IP protocols and be more verbose with
comments.
Diffstat (limited to 'sys/netinet6/ip6_input.c')
-rw-r--r--sys/netinet6/ip6_input.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index dc3b318..32cd04e 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -169,13 +169,22 @@ ip6_init()
pr = (struct ip6protosw *)pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW);
if (pr == 0)
panic("ip6_init");
+
+ /* Initialize the entire ip_protox[] array to IPPROTO_RAW. */
for (i = 0; i < IPPROTO_MAX; i++)
ip6_protox[i] = pr - inet6sw;
+ /*
+ * Cycle through IP protocols and put them into the appropriate place
+ * in ip6_protox[].
+ */
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)
- ip6_protox[pr->pr_protocol] = pr - inet6sw;
+ pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) {
+ /* Be careful to only index valid IP protocols. */
+ if (pr->pr_protocol <= IPPROTO_MAX)
+ ip6_protox[pr->pr_protocol] = pr - inet6sw;
+ }
/* Initialize packet filter hooks. */
inet6_pfil_hook.ph_type = PFIL_TYPE_AF;
OpenPOWER on IntegriCloud