diff options
author | Christian Weisgerber <naddy@cvs.openbsd.org> | 2002-06-24 12:37:21 +0000 |
---|---|---|
committer | Christian Weisgerber <naddy@cvs.openbsd.org> | 2002-06-24 12:37:21 +0000 |
commit | c3775af2006f2121f8b1a6ffa3477c4134fbc05d (patch) | |
tree | 8000c1f1d9e4ed8879169dc8a3f381a6b6339819 | |
parent | 134630668c9de9dc69b589d628381419f543ff2e (diff) |
prevent potential unaligned access error; ok espie@, pval@
-rw-r--r-- | usr.bin/locate/locate/util.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/locate/locate/util.c b/usr.bin/locate/locate/util.c index 839b03791e0..cb0bc972994 100644 --- a/usr.bin/locate/locate/util.c +++ b/usr.bin/locate/locate/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.5 2002/02/16 21:27:48 millert Exp $ +/* $OpenBSD: util.c,v 1.6 2002/06/24 12:37:20 naddy Exp $ * * Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. * Copyright (c) 1989, 1993 @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: util.c,v 1.5 2002/02/16 21:27:48 millert Exp $ + * $Id: util.c,v 1.6 2002/06/24 12:37:20 naddy Exp $ */ @@ -231,13 +231,16 @@ int getwm(p) caddr_t p; { - static char buf[INTSIZE]; + union { + char buf[INTSIZE]; + int i; + } u; int i; for (i = 0; i < INTSIZE; i++) - buf[i] = *p++; + u.buf[i] = *p++; - i = *(int *)buf; + i = u.i; if (i > MAXPATHLEN || i < -(MAXPATHLEN)) { i = ntohl(i); |