Fix handling of the third argument for fcntl(2). The native syscall

uses long for arg, which needs translation.

Discussed with and tested by:	mjg
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
kib 2014-08-27 01:02:02 +00:00
parent 4900dd0aa5
commit 75f74b437b
2 changed files with 27 additions and 1 deletions

View File

@ -2980,3 +2980,28 @@ freebsd32_procctl(struct thread *td, struct freebsd32_procctl_args *uap)
return (kern_procctl(td, uap->idtype, PAIR32TO64(id_t, uap->id),
uap->com, data));
}
int
freebsd32_fcntl(struct thread *td, struct freebsd32_fcntl_args *uap)
{
intptr_t tmp;
switch (uap->cmd) {
/*
* Do unsigned conversion for arg when operation
* interprets it as flags or pointer.
*/
case F_SETLK_REMOTE:
case F_SETLKW:
case F_SETLK:
case F_GETLK:
case F_SETFD:
case F_SETFL:
tmp = (unsigned int)(uap->arg);
break;
default:
tmp = uap->arg;
break;
}
return (kern_fcntl(td, uap->fd, uap->cmd, tmp));
}

View File

@ -200,7 +200,8 @@
89 AUE_GETDTABLESIZE NOPROTO { int getdtablesize(void); }
90 AUE_DUP2 NOPROTO { int dup2(u_int from, u_int to); }
91 AUE_NULL UNIMPL getdopt
92 AUE_FCNTL NOPROTO { int fcntl(int fd, int cmd, long arg); }
92 AUE_FCNTL STD { int freebsd32_fcntl(int fd, int cmd, \
int arg); }
93 AUE_SELECT STD { int freebsd32_select(int nd, fd_set *in, \
fd_set *ou, fd_set *ex, \
struct timeval32 *tv); }