summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2004-11-25 23:08:13 +0000
committerderaadt <deraadt@openbsd.org>2004-11-25 23:08:13 +0000
commit3e4efdf5bbf371aaeafac8202e6577a0aee4ffa9 (patch)
tree832711a95b0467f41712a8491bb7e05aa85ab5dc
parentleak; from mpech (diff)
downloadwireguard-openbsd-3e4efdf5bbf371aaeafac8202e6577a0aee4ffa9.tar.xz
wireguard-openbsd-3e4efdf5bbf371aaeafac8202e6577a0aee4ffa9.zip
fix on alpha. the lack of BWX by default, and assumptions of alignment
keep biting us hard for structures that happen to have been plopped at unaligned objects. terrible decisions made at DEC ages ago, and compounded by terrible gcc decisions cause us to make workarounds all the time. showed by markus, found by David Berghoff
-rw-r--r--usr.bin/systat/if.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/usr.bin/systat/if.c b/usr.bin/systat/if.c
index 0045695b85e..8153ee3c3d8 100644
--- a/usr.bin/systat/if.c
+++ b/usr.bin/systat/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.1 2004/11/16 09:52:33 markus Exp $ */
+/* $OpenBSD: if.c,v 1.2 2004/11/25 23:08:13 deraadt Exp $ */
/*
* Copyright (c) 2004 Markus Friedl <markus@openbsd.org>
*
@@ -75,7 +75,7 @@ initifstat(void)
}
#define UPDATE(x, y) do { \
- ifs->ifs_now.x = ifm->y; \
+ ifs->ifs_now.x = ifm.y; \
ifs->ifs_cur.x = ifs->ifs_now.x - ifs->ifs_old.x; \
sum.x += ifs->ifs_cur.x; \
if (state == TIME) \
@@ -102,7 +102,7 @@ void
fetchifstat(void)
{
struct ifstat *newstats, *ifs;
- struct if_msghdr *ifm;
+ struct if_msghdr ifm;
struct sockaddr *info[RTAX_MAX];
struct sockaddr_dl *sdl;
char *buf, *next, *lim;
@@ -128,24 +128,25 @@ fetchifstat(void)
bzero(&sum, sizeof(sum));
lim = buf + need;
- for (next = buf; next < lim; next += ifm->ifm_msglen) {
- ifm = (struct if_msghdr *)next;
- if (ifm->ifm_type != RTM_IFINFO ||
- !(ifm->ifm_addrs & RTA_IFP))
+ for (next = buf; next < lim; next += ifm.ifm_msglen) {
+ bcopy(next, &ifm, sizeof ifm);
+ if (ifm.ifm_type != RTM_IFINFO ||
+ !(ifm.ifm_addrs & RTA_IFP))
continue;
- if (ifm->ifm_index >= nifs) {
- if ((newstats = realloc(ifstats, (ifm->ifm_index + 4) *
+ if (ifm.ifm_index >= nifs) {
+ if ((newstats = realloc(ifstats, (ifm.ifm_index + 4) *
sizeof(struct ifstat))) == NULL)
continue;
ifstats = newstats;
- for (; nifs < ifm->ifm_index + 4; nifs++)
+ for (; nifs < ifm.ifm_index + 4; nifs++)
ifstats[nifs].ifs_name[0] = '\0';
}
- ifs = &ifstats[ifm->ifm_index];
+ ifs = &ifstats[ifm.ifm_index];
if (ifs->ifs_name[0] == '\0') {
bzero(&info, sizeof(info));
- rt_getaddrinfo((struct sockaddr *)(ifm + 1),
- ifm->ifm_addrs, info);
+ rt_getaddrinfo(
+ (struct sockaddr *)((struct if_msghdr *)next + 1),
+ ifm.ifm_addrs, info);
if ((sdl = (struct sockaddr_dl *)info[RTAX_IFP])) {
if (sdl->sdl_family == AF_LINK &&
sdl->sdl_nlen > 0)