mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-16 07:20:46 +00:00
LibPthread: Validate the clock argument in pthread_condattr_setclock
This commit is contained in:
parent
84962fcc9b
commit
c6f745de27
Notes:
sideshowbarker
2024-07-17 21:21:18 +09:00
Author: https://github.com/bgianfo
Commit: c6f745de27
Pull-request: https://github.com/SerenityOS/serenity/pull/11750
Reviewed-by: https://github.com/alimpfard
1 changed files with 11 additions and 2 deletions
|
@ -39,8 +39,17 @@ int pthread_condattr_getclock(pthread_condattr_t* attr, clockid_t* clock)
|
|||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_condattr_setclock.html
|
||||
int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock)
|
||||
{
|
||||
attr->clockid = clock;
|
||||
return 0;
|
||||
switch (clock) {
|
||||
case CLOCK_REALTIME:
|
||||
case CLOCK_REALTIME_COARSE:
|
||||
case CLOCK_MONOTONIC:
|
||||
case CLOCK_MONOTONIC_COARSE:
|
||||
case CLOCK_MONOTONIC_RAW:
|
||||
attr->clockid = clock;
|
||||
return 0;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
// Condition variables.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue