Skip to content

Commit 13f4ac4

Browse files
committed
ipc: linux: enforce IFNAMSIZ limit
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 <[email protected]>
1 parent 729242a commit 13f4ac4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: src/ipc-linux.h

+6
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,12 @@ static int kernel_get_device(struct wgdevice **device, const char *iface)
479479
struct nlmsghdr *nlh;
480480
struct mnlg_socket *nlg;
481481

482+
/* libmnl doesn't check the buffer size, so enforce that before using. */
483+
if (strlen(iface) >= IFNAMSIZ) {
484+
errno = ENAMETOOLONG;
485+
return -ENAMETOOLONG;
486+
}
487+
482488
try_again:
483489
ret = 0;
484490
*device = calloc(1, sizeof(**device));

0 commit comments

Comments
 (0)