From d2ba455c2c78c4533e00614ad10c6f238abaa97f Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 9 May 2000 17:43:21 +0000 Subject: [PATCH] Some ioctl routines assume that the ioctl buffer is aligned, but a char[] declaration makes no such guarentee. A union is used to force alignment of the char buffer. --- sys/kern/sys_generic.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 5ef9059e5deb..687e4f94d4af 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -496,7 +496,10 @@ ioctl(p, uap) caddr_t data, memp; int tmp; #define STK_PARAMS 128 - char stkbuf[STK_PARAMS]; + union { + char stkbuf[STK_PARAMS]; + long align; + } ubuf; fdp = p->p_fd; if ((u_int)uap->fd >= fdp->fd_nfiles || @@ -523,11 +526,11 @@ ioctl(p, uap) if (size > IOCPARM_MAX) return (ENOTTY); memp = NULL; - if (size > sizeof (stkbuf)) { + if (size > sizeof (ubuf.stkbuf)) { memp = (caddr_t)malloc((u_long)size, M_IOCTLOPS, M_WAITOK); data = memp; } else - data = stkbuf; + data = ubuf.stkbuf; if (com&IOC_IN) { if (size) { error = copyin(uap->data, data, (u_int)size);