Skip to content

Commit

Permalink
ipc: linux: enforce IFNAMSIZ limit
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
zx2c4 committed Aug 4, 2023
1 parent 729242a commit 13f4ac4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ipc-linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

1 comment on commit 13f4ac4

@Neustradamus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zx2c4: A new build is planned?

The latest will be 2 years soon:

Please sign in to comment.