mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-22 03:04:34 +01:00
libthr: avoid varargs in fcntl and openat interposers
Align these signatures with the ones in syscalls.master (and thus libsys.h). There's no reason to do va_args twice and in some ABIs (e.g,, CheriABI) you can't access fixed arguments as varargs if you weren't called with varargs signature. Reviewed by: imp, kib, jhibbits Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D45126
This commit is contained in:
parent
2a9aae9e5f
commit
ec2b6b16aa
@ -864,8 +864,8 @@ int _pthread_mutexattr_setrobust(pthread_mutexattr_t * _Nonnull, int);
|
||||
/* #include <fcntl.h> */
|
||||
#ifdef _SYS_FCNTL_H_
|
||||
#ifndef _LIBC_PRIVATE_H_
|
||||
int __sys_fcntl(int, int, ...);
|
||||
int __sys_openat(int, const char *, int, ...);
|
||||
int __sys_fcntl(int, int, intptr_t);
|
||||
int __sys_openat(int, const char *, int, int);
|
||||
#endif /* _LIBC_PRIVATE_H_ */
|
||||
#endif /* _SYS_FCNTL_H_ */
|
||||
|
||||
|
@ -188,22 +188,19 @@ __thr_connect(int fd, const struct sockaddr *name, socklen_t namelen)
|
||||
* if it is canceled.
|
||||
*/
|
||||
static int
|
||||
__thr_fcntl(int fd, int cmd, ...)
|
||||
__thr_fcntl(int fd, int cmd, __intptr_t arg)
|
||||
{
|
||||
struct pthread *curthread;
|
||||
int ret;
|
||||
va_list ap;
|
||||
|
||||
curthread = _get_curthread();
|
||||
va_start(ap, cmd);
|
||||
if (cmd == F_OSETLKW || cmd == F_SETLKW) {
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_fcntl(fd, cmd, (intptr_t)va_arg(ap, void *));
|
||||
ret = __sys_fcntl(fd, cmd, arg);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
} else {
|
||||
ret = __sys_fcntl(fd, cmd, (intptr_t)va_arg(ap, void *));
|
||||
ret = __sys_fcntl(fd, cmd, arg);
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
@ -294,23 +291,11 @@ __thr_nanosleep(const struct timespec *time_to_sleep,
|
||||
* If the thread is canceled, file is not opened.
|
||||
*/
|
||||
static int
|
||||
__thr_openat(int fd, const char *path, int flags, ...)
|
||||
__thr_openat(int fd, const char *path, int flags, int mode)
|
||||
{
|
||||
struct pthread *curthread;
|
||||
int mode, ret;
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
|
||||
/* Check if the file is being created: */
|
||||
if ((flags & O_CREAT) != 0) {
|
||||
/* Get the creation mode: */
|
||||
va_start(ap, flags);
|
||||
mode = va_arg(ap, int);
|
||||
va_end(ap);
|
||||
} else {
|
||||
mode = 0;
|
||||
}
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_openat(fd, path, flags, mode);
|
||||
|
Loading…
Reference in New Issue
Block a user