nxsig_clockwait: add Parameter Check.

Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
This commit is contained in:
yangguangcai 2024-08-05 14:44:38 +08:00 committed by Xiang Xiao
parent fc73dfd368
commit 475bbfc165
1 changed files with 7 additions and 1 deletions

View File

@ -257,6 +257,11 @@ int nxsig_clockwait(int clockid, int flags,
clock_t expect;
clock_t stop;
if (rqtp && (rqtp->tv_nsec < 0 || rqtp->tv_nsec >= 1000000000))
{
return -EINVAL;
}
/* If rqtp is zero, yield CPU and return
* Notice: The behavior of sleep(0) is not defined in POSIX, so there are
* different implementations:
@ -304,7 +309,8 @@ int nxsig_clockwait(int clockid, int flags,
expect += clock_systime_ticks();
}
wd_start_absolute(&rtcb->waitdog, expect, nxsig_timeout, (wdparm_t)rtcb);
wd_start_absolute(&rtcb->waitdog, expect,
nxsig_timeout, (wdparm_t)rtcb);
}
/* Remove the tcb task from the ready-to-run list. */