From d18b479b1d3522112335515dcddb4a9fcf4d684b Mon Sep 17 00:00:00 2001 From: otto Date: Mon, 19 Feb 2018 09:52:16 +0000 Subject: [PATCH] (static) byte buffers are not aligned in any way, malloc the buffer to solve that. Prevents bus error on armv7. ok naddy@ florian@ --- sbin/slaacd/frontend.c | 16 +++++++++++----- 1 file 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 @@ -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; } -- 2.20.1