From 34ebc4e1ba41c618e5d46112696011ed596c5ebc Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Sun, 11 Dec 2022 16:28:28 +0100 Subject: [PATCH] BSD: Workaround for direct routes on FreeBSD 13.0 FreeBSD 13.0 added some safechecks for syscalls, rejecting sockaddrs that are too small, later versions loosen up the check. --- sysdep/bsd/krt-sock.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sysdep/bsd/krt-sock.c b/sysdep/bsd/krt-sock.c index 256c4ed0..47f5cf59 100644 --- a/sysdep/bsd/krt-sock.c +++ b/sysdep/bsd/krt-sock.c @@ -190,6 +190,10 @@ static inline void sockaddr_fill_dl(struct sockaddr_dl *sa, struct iface *ifa) { uint len = OFFSETOF(struct sockaddr_dl, sdl_data); + + /* Workaround for FreeBSD 13.0 */ + len = MAX(len, sizeof(struct sockaddr)); + memset(sa, 0, len); sa->sdl_len = len; sa->sdl_family = AF_LINK;