aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2023-08-04 16:04:36 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2023-08-04 16:04:36 +0200
commit13f4ac4cb74b5a833fa7f825ba785b1e5774e84f (patch)
tree198559247d53267080d051a94797f1307c1ca1b0
parentman: set private key in PreUp rather than PostUp (diff)
downloadwireguard-tools-master.tar.xz
wireguard-tools-master.zip
ipc: linux: enforce IFNAMSIZ limitHEADmaster
libmnl doesn't check lengths, so do our own checking before copying the interface name to the netlink buffer. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--src/ipc-linux.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ipc-linux.h b/src/ipc-linux.h
index 5883ffe..d29c0c5 100644
--- a/src/ipc-linux.h
+++ b/src/ipc-linux.h
@@ -479,6 +479,12 @@ static int kernel_get_device(struct wgdevice **device, const char *iface)
struct nlmsghdr *nlh;
struct mnlg_socket *nlg;
+ /* libmnl doesn't check the buffer size, so enforce that before using. */
+ if (strlen(iface) >= IFNAMSIZ) {
+ errno = ENAMETOOLONG;
+ return -ENAMETOOLONG;
+ }
+
try_again:
ret = 0;
*device = calloc(1, sizeof(**device));