summaryrefslogtreecommitdiff
path: root/sys/netinet6
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2023-01-24 20:06:17 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2023-01-24 20:06:17 +0000
commitc03dbc1776b5842f83ee95ff1aa286570304138d (patch)
tree598e154e6b5670b89ab54910199f564dfe43220e /sys/netinet6
parent08551af8ab8b57f2b52b3ac6865315f58c1345a7 (diff)
Refactor nd6_options() a bit more. Rewrite the loop to be a proper loop
and not some endless loop with some gotos. OK kn@
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/nd6.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 4a52ae1561e..ee5a250e6e3 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6.c,v 1.264 2023/01/06 14:35:34 kn Exp $ */
+/* $OpenBSD: nd6.c,v 1.265 2023/01/24 20:06:16 claudio Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
@@ -145,7 +145,7 @@ nd6_ifdetach(struct ifnet *ifp)
int
nd6_options(void *opt, int icmp6len, struct nd_opts *ndopts)
{
- struct nd_opt_hdr *nd_opt = opt, *next_opt, *last_opt;
+ struct nd_opt_hdr *nd_opt, *next_opt, *last_opt;
int i = 0;
bzero(ndopts, sizeof(*ndopts));
@@ -153,15 +153,12 @@ nd6_options(void *opt, int icmp6len, struct nd_opts *ndopts)
if (icmp6len == 0)
return 0;
- next_opt = nd_opt;
- last_opt = (struct nd_opt_hdr *)((u_char *)nd_opt + icmp6len);
+ next_opt = opt;
+ last_opt = (struct nd_opt_hdr *)((u_char *)opt + icmp6len);
- while (1) {
+ while (next_opt != NULL) {
int olen;
- if (next_opt == NULL)
- goto skip1;
-
nd_opt = next_opt;
/* make sure nd_opt_len is inside the buffer */
@@ -215,16 +212,12 @@ nd6_options(void *opt, int icmp6len, struct nd_opts *ndopts)
break;
}
-skip1:
i++;
if (i > nd6_maxndopt) {
icmp6stat_inc(icp6s_nd_toomanyopt);
nd6log((LOG_INFO, "too many loop in nd opt\n"));
break;
}
-
- if (next_opt == NULL)
- break;
}
return 0;