From: tedu Date: Sun, 10 Jul 2016 23:06:48 +0000 (+0000) Subject: use offsetof to create an offset instead of illegal unaligned pointers X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=50e7fddbb83f13920d11a4e02f277e6e34f293d6;p=openbsd use offsetof to create an offset instead of illegal unaligned pointers ok guenther --- 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)); } /*