diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2018-02-19 09:52:17 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2018-02-19 09:52:17 +0000 |
commit | 7d82c9faabd11571f64ea879140261261f9c4d4e (patch) | |
tree | b09663844313c29064b871f67b2b6e962ff21777 /sbin/slaacd/frontend.c | |
parent | 645ba136a4b6fcc8245066b988f50c75fb1b9688 (diff) |
(static) byte buffers are not aligned in any way, malloc the buffer to
solve that. Prevents bus error on armv7. ok naddy@ florian@
Diffstat (limited to 'sbin/slaacd/frontend.c')
-rw-r--r-- | sbin/slaacd/frontend.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sbin/slaacd/frontend.c b/sbin/slaacd/frontend.c index 171cfe251b0..c2c6637740a 100644 --- a/sbin/slaacd/frontend.c +++ b/sbin/slaacd/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.11 2018/02/10 05:57:59 florian Exp $ */ +/* $OpenBSD: frontend.c,v 1.12 2018/02/19 09:52:16 otto Exp $ */ /* * Copyright (c) 2017 Florian Obser <florian@openbsd.org> @@ -630,13 +630,19 @@ frontend_startup(void) void route_receive(int fd, short events, void *arg) { - static uint8_t buf[ROUTE_SOCKET_BUF_SIZE]; + static uint8_t *buf; - struct rt_msghdr *rtm = (struct rt_msghdr *)buf; + struct rt_msghdr *rtm; struct sockaddr *sa, *rti_info[RTAX_MAX]; ssize_t n; - if ((n = read(fd, &buf, sizeof(buf))) == -1) { + if (buf == NULL) { + buf = malloc(ROUTE_SOCKET_BUF_SIZE); + if (buf == NULL) + fatal("malloc"); + } + rtm = (struct rt_msghdr *)buf; + if ((n = read(fd, buf, ROUTE_SOCKET_BUF_SIZE)) == -1) { if (errno == EAGAIN || errno == EINTR) return; log_warn("dispatch_rtmsg: read error"); @@ -647,7 +653,7 @@ route_receive(int fd, short events, void *arg) fatal("routing socket closed"); if (n < rtm->rtm_msglen) { - log_warnx("partial rtm in buffer"); + log_warnx("partial rtm of %zd in buffer", n); return; } |