libroot: check timeout interval parameter in ppoll(), pselect() and select()
* also introduce timeval_to_bigtime * time_private is c++ only Change-Id: I2bddbe5f95240735c7b42ccf429dcbb3f1e8bb1b Reviewed-on: https://review.haiku-os.org/c/haiku/+/5220 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]> Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
30294b6d05
commit
eb22dbd032
@@ -67,6 +67,14 @@ timeval_to_timespec(const timeval& val, timespec& spec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
timeval_to_bigtime(const timeval& val, bigtime_t& _time)
|
||||||
|
{
|
||||||
|
timespec spec;
|
||||||
|
return timeval_to_timespec(val, spec) && timespec_to_bigtime(spec, _time);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
timespec_to_timeval(const timespec& spec, timeval& val)
|
timespec_to_timeval(const timespec& spec, timeval& val)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ KernelMergeObject kernel_lib_posix.o :
|
|||||||
kernel_errno.cpp
|
kernel_errno.cpp
|
||||||
dirent.c
|
dirent.c
|
||||||
fcntl.cpp
|
fcntl.cpp
|
||||||
poll.c
|
poll.cpp
|
||||||
utime.c
|
utime.c
|
||||||
# locale
|
# locale
|
||||||
ctype.cpp
|
ctype.cpp
|
||||||
@@ -77,7 +77,7 @@ KernelMergeObject kernel_lib_posix.o :
|
|||||||
chmod.c
|
chmod.c
|
||||||
stat.c
|
stat.c
|
||||||
mkdir.c
|
mkdir.c
|
||||||
select.c
|
select.cpp
|
||||||
gettimeofday.c
|
gettimeofday.c
|
||||||
uio.c
|
uio.c
|
||||||
# time
|
# time
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
|||||||
inttypes.c
|
inttypes.c
|
||||||
libgen.cpp
|
libgen.cpp
|
||||||
nftw.c
|
nftw.c
|
||||||
poll.c
|
poll.cpp
|
||||||
$(PWD_BACKEND)
|
$(PWD_BACKEND)
|
||||||
scheduler.cpp
|
scheduler.cpp
|
||||||
semaphore.cpp
|
semaphore.cpp
|
||||||
|
|||||||
@@ -13,9 +13,10 @@
|
|||||||
|
|
||||||
#include <errno_private.h>
|
#include <errno_private.h>
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
|
#include <time_private.h>
|
||||||
|
|
||||||
|
|
||||||
int __ppoll(struct pollfd *fds, nfds_t numfds, const struct timespec *tv,
|
extern "C" int __ppoll(struct pollfd *fds, nfds_t numfds, const struct timespec *tv,
|
||||||
const sigset_t *sigMask);
|
const sigset_t *sigMask);
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -32,8 +33,8 @@ __ppoll(struct pollfd *fds, nfds_t numfds, const struct timespec *tv,
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
bigtime_t timeout = -1LL;
|
bigtime_t timeout = -1LL;
|
||||||
if (tv)
|
if (tv != NULL && !timespec_to_bigtime(*tv, timeout))
|
||||||
timeout = tv->tv_sec * 1000000LL + tv->tv_nsec / 1000LL;
|
RETURN_AND_SET_ERRNO_TEST_CANCEL(EINVAL);
|
||||||
|
|
||||||
status = _kern_poll(fds, numfds, timeout, sigMask);
|
status = _kern_poll(fds, numfds, timeout, sigMask);
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
|||||||
mman.cpp
|
mman.cpp
|
||||||
priority.c
|
priority.c
|
||||||
rlimit.c
|
rlimit.c
|
||||||
select.c
|
select.cpp
|
||||||
stat.c
|
stat.c
|
||||||
statvfs.c
|
statvfs.c
|
||||||
times.cpp
|
times.cpp
|
||||||
|
|||||||
@@ -13,16 +13,16 @@
|
|||||||
#include <syscall_utils.h>
|
#include <syscall_utils.h>
|
||||||
|
|
||||||
#include <errno_private.h>
|
#include <errno_private.h>
|
||||||
|
#include <signal_private.h>
|
||||||
#include <symbol_versioning.h>
|
#include <symbol_versioning.h>
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
|
#include <time_private.h>
|
||||||
#include <signal_private.h>
|
|
||||||
|
|
||||||
|
|
||||||
int __pselect_beos(int numBits, struct fd_set *readBits,
|
extern "C" int __pselect_beos(int numBits, struct fd_set *readBits,
|
||||||
struct fd_set *writeBits, struct fd_set *errorBits,
|
struct fd_set *writeBits, struct fd_set *errorBits,
|
||||||
const struct timespec *tv, const sigset_t *beosSignalMask);
|
const struct timespec *tv, const sigset_t *beosSignalMask);
|
||||||
int __pselect(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
|
extern "C" int __pselect(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
|
||||||
struct fd_set *errorBits, const struct timespec *tv,
|
struct fd_set *errorBits, const struct timespec *tv,
|
||||||
const sigset_t *sigMask);
|
const sigset_t *sigMask);
|
||||||
|
|
||||||
@@ -35,8 +35,8 @@ __pselect_beos(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
|
|||||||
int status;
|
int status;
|
||||||
sigset_t signalMask;
|
sigset_t signalMask;
|
||||||
bigtime_t timeout = -1LL;
|
bigtime_t timeout = -1LL;
|
||||||
if (tv)
|
if (tv != NULL && !timespec_to_bigtime(*tv, timeout))
|
||||||
timeout = tv->tv_sec * 1000000LL + tv->tv_nsec / 1000LL;
|
RETURN_AND_SET_ERRNO_TEST_CANCEL(EINVAL);
|
||||||
|
|
||||||
if (beosSignalMask != NULL)
|
if (beosSignalMask != NULL)
|
||||||
signalMask = from_beos_sigset(*beosSignalMask);
|
signalMask = from_beos_sigset(*beosSignalMask);
|
||||||
@@ -55,8 +55,8 @@ __pselect(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
bigtime_t timeout = -1LL;
|
bigtime_t timeout = -1LL;
|
||||||
if (tv)
|
if (tv != NULL && !timespec_to_bigtime(*tv, timeout))
|
||||||
timeout = tv->tv_sec * 1000000LL + tv->tv_nsec / 1000LL;
|
RETURN_AND_SET_ERRNO_TEST_CANCEL(EINVAL);
|
||||||
|
|
||||||
status = _kern_select(numBits, readBits, writeBits, errorBits, timeout,
|
status = _kern_select(numBits, readBits, writeBits, errorBits, timeout,
|
||||||
sigMask);
|
sigMask);
|
||||||
@@ -71,8 +71,8 @@ select(int numBits, struct fd_set *readBits, struct fd_set *writeBits,
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
bigtime_t timeout = -1LL;
|
bigtime_t timeout = -1LL;
|
||||||
if (tv)
|
if (tv != NULL && !timeval_to_bigtime(*tv, timeout))
|
||||||
timeout = tv->tv_sec * 1000000LL + tv->tv_usec;
|
RETURN_AND_SET_ERRNO_TEST_CANCEL(EINVAL);
|
||||||
|
|
||||||
status = _kern_select(numBits, readBits, writeBits, errorBits, timeout,
|
status = _kern_select(numBits, readBits, writeBits, errorBits, timeout,
|
||||||
NULL);
|
NULL);
|
||||||
Reference in New Issue
Block a user