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.
This commit is contained in:
parent
db44ba3753
commit
34f50cffe7
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user