summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2016-07-10 23:06:49 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2016-07-10 23:06:49 +0000
commit79dd30fcd5ee6d38307f9c7eee575499fe4db6b7 (patch)
treed32d99c6f6df03c61796ee0f923ea6ee9a2c9c7a /lib
parent895ea6ba313ef89fa2d827547849fb2a9e3a63bd (diff)
use offsetof to create an offset instead of illegal unaligned pointers
ok guenther
Diffstat (limited to 'lib')
-rw-r--r--lib/libkvm/kvm.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c
index a2f699dbbd6..5247cffb9f4 100644
--- a/lib/libkvm/kvm.c
+++ b/lib/libkvm/kvm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm.c,v 1.61 2016/05/14 14:24:54 kettenis Exp $ */
+/* $OpenBSD: kvm.c,v 1.62 2016/07/10 23:06:48 tedu Exp $ */
/* $NetBSD: kvm.c,v 1.43 1996/05/05 04:31:59 gwr Exp $ */
/*-
@@ -44,6 +44,7 @@
#include <sys/exec.h>
#include <sys/kcore.h>
+#include <stddef.h>
#include <errno.h>
#include <ctype.h>
#include <db.h>
@@ -791,9 +792,9 @@ kvm_nlist(kvm_t *kd, struct nlist *nl)
/*
* Avoid alignment issues.
*/
- bcopy(&((struct nlist *)rec.data)->n_type,
+ bcopy((char *)rec.data + offsetof(struct nlist, n_type),
&p->n_type, sizeof(p->n_type));
- bcopy(&((struct nlist *)rec.data)->n_value,
+ bcopy((char *)rec.data + offsetof(struct nlist, n_value),
&p->n_value, sizeof(p->n_value));
}
/*