summaryrefslogtreecommitdiffstats
path: root/sys/net/if_wg.c
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@noconroy.net>2021-03-28 09:19:47 +1100
committerMatt Dunwoodie <ncon@noconroy.net>2021-04-13 15:47:30 +1000
commit68de77e987c33ef3f9a8cfa9ce6d85d0798f9784 (patch)
tree81a0890852dc02d06ab3bfbfcebd00524916db3b /sys/net/if_wg.c
parentAllow setting keepalive while interface is down (diff)
downloadwireguard-openbsd-68de77e987c33ef3f9a8cfa9ce6d85d0798f9784.tar.xz
wireguard-openbsd-68de77e987c33ef3f9a8cfa9ce6d85d0798f9784.zip
Check iter != NULL
The problem with checking peer != NULL is that we already dereference iter to get i_value. This is what was caught in the index == 0 bug reported on bugs@. Instead, we should assert that iter != NULL. This is likely to be removed when adjusting wg_noise.c in the not to distant future.
Diffstat (limited to '')
-rw-r--r--sys/net/if_wg.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/net/if_wg.c b/sys/net/if_wg.c
index 3de52a588cb..807d08a7b6e 100644
--- a/sys/net/if_wg.c
+++ b/sys/net/if_wg.c
@@ -1965,9 +1965,9 @@ wg_index_drop(void *_sc, uint32_t key0)
}
mtx_leave(&sc->sc_index_mtx);
- /* We expect a peer */
+ /* We expect an index match */
+ KASSERT(iter != NULL);
peer = CONTAINER_OF(iter->i_value, struct wg_peer, p_remote);
- KASSERT(peer != NULL);
SLIST_INSERT_HEAD(&peer->p_unused_index, iter, i_unused_entry);
}