aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2021-04-10 15:25:24 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2021-04-19 18:52:57 +0000
commitde703e98e6c863874aa6012e3ce1a61eee58c846 (patch)
tree84273a9c502e81854c8f9c05fe00b3524cc80893
parent5c00c82245764546b30c7152417cd6470fb16ac5 (diff)
downloadsrc-de703e98e6c863874aa6012e3ce1a61eee58c846.tar.gz
src-de703e98e6c863874aa6012e3ce1a61eee58c846.zip
Fix direct route installation with net/bird.
Slighly relax the gateway validation rules imposed by the 2fe5a79425c7, by requiring only first 8 bytes (everyhing before sdl_data to be present in the AF_LINK gateway. Reported by: olivier PR: 255089 (cherry picked from commit 7f5f3fcc32bfa553faa007579dfcaed84be3b047)
-rw-r--r--sys/net/rtsock.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 12e485f917c8..c0996d318fb2 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1381,20 +1381,21 @@ cleanup_xaddrs_gateway(struct rt_addrinfo *info)
#endif
case AF_LINK:
{
- struct sockaddr_dl_short *gw_sdl;
+ struct sockaddr_dl *gw_sdl;
- gw_sdl = (struct sockaddr_dl_short *)gw;
- if (gw_sdl->sdl_len < sizeof(struct sockaddr_dl_short)) {
+ size_t sdl_min_len = offsetof(struct sockaddr_dl, sdl_data);
+ gw_sdl = (struct sockaddr_dl *)gw;
+ if (gw_sdl->sdl_len < sdl_min_len) {
printf("gw sdl_len too small\n");
return (EINVAL);
}
const struct sockaddr_dl_short sdl = {
.sdl_family = AF_LINK,
- .sdl_len = sizeof(struct sockaddr_dl_short),
+ .sdl_len = sdl_min_len,
.sdl_index = gw_sdl->sdl_index,
};
- *gw_sdl = sdl;
+ memcpy(gw_sdl, &sdl, sdl_min_len);
break;
}
}