From c6f745de27810ce364df3a23716ed213ccd06e52 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sat, 8 Jan 2022 19:57:53 -0800 Subject: [PATCH] LibPthread: Validate the clock argument in pthread_condattr_setclock --- Userland/Libraries/LibPthread/pthread_cond.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibPthread/pthread_cond.cpp b/Userland/Libraries/LibPthread/pthread_cond.cpp index c6238a6274..f63978c988 100644 --- a/Userland/Libraries/LibPthread/pthread_cond.cpp +++ b/Userland/Libraries/LibPthread/pthread_cond.cpp @@ -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.