nd_opts_{search,last,done} are exlusively used in the internal option
handling machinery; the only two nd6_options() callers only use
nd_opts_{src,tgt}_lladdr.
nd6_options() always zeroes and initialises the caller's struct nd_opts.
If icmp6len is zero, i.e. if there are no ICMP6 header options left,
everything inside *ndopts is zero, except nd_opts_done=1 which is not
used by the callers.
Set the internal nd_opts_{search,last,done} members only when needed.
OK claudio
-/* $OpenBSD: nd6.c,v 1.260 2022/12/10 21:26:21 kn Exp $ */
+/* $OpenBSD: nd6.c,v 1.261 2023/01/06 14:24:36 kn Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
int i = 0;
bzero(ndopts, sizeof(*ndopts));
+
+ if (icmp6len == 0)
+ return 0;
+
ndopts->nd_opts_search = nd_opt;
ndopts->nd_opts_last =
(struct nd_opt_hdr *)(((u_char *)nd_opt) + icmp6len);
- if (icmp6len == 0) {
- ndopts->nd_opts_done = 1;
- ndopts->nd_opts_search = NULL;
- return 0;
- }
-
while (1) {
nd_opt = nd6_option(ndopts);
if (nd_opt == NULL && ndopts->nd_opts_last == NULL) {