]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commit
ipc: freebsd: avoid leaking memory in kernel_get_device()
authorKyle Evans <kevans@FreeBSD.org>
Thu, 3 Nov 2022 17:59:01 +0000 (12:59 -0500)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 3 Nov 2022 18:57:21 +0000 (19:57 +0100)
commitdbf49a7d17d69b8af365ce2521df110a4710c819
treeaa779b1d9233c4f5838e57f0e542a70b6d1f13a8
parentca2e89ff21794b1853f628b8d5cb0f91eb140461
ipc: freebsd: avoid leaking memory in kernel_get_device()

Primarily, front-load validation of an allowed-ip entry to before we
allocate `aip`, so that we don't need to free() it if we end up skipping
this entry.  Assert that `aip` is NULL after we exit the loop, as we
should have transfered ownership to the `peer` or freed it in all paths
through the allowed-ip loop.

FreeBSD-Coverity: 1500405
Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
src/ipc-freebsd.h