Detect sign-extension bugs in the ioctl(2) command argument: Truncate

to 32 bits and print warning.
This commit is contained in:
Poul-Henning Kamp 2005-01-18 07:37:05 +00:00
parent bb5d43ae2a
commit 9fc6aa0618
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=140406

View File

@ -472,6 +472,12 @@ ioctl(struct thread *td, struct ioctl_args *uap)
caddr_t data, memp;
int tmp;
if (uap->com > 0xffffffff) {
printf(
"WARNING pid %d (%s): ioctl sign-extension ioctl %lx\n",
td->td_proc->p_pid, td->td_proc->p_comm, uap->com);
uap->com &= 0xffffffff;
}
if ((error = fget(td, uap->fd, &fp)) != 0)
return (error);
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {