From 50e7fddbb83f13920d11a4e02f277e6e34f293d6 Mon Sep 17 00:00:00 2001 From: tedu Date: Sun, 10 Jul 2016 23:06:48 +0000 Subject: [PATCH] use offsetof to create an offset instead of illegal unaligned pointers ok guenther --- lib/libkvm/kvm.c | 7 ++++--- 1 file 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 #include +#include #include #include #include @@ -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)); } /* -- 2.20.1