|
|
Message-ID: <20241224020301.1673274-1-yan.li.cn@windriver.com>
Date: Tue, 24 Dec 2024 10:03:01 +0800
From: <yan.li.cn@...driver.com>
To: <musl@...ts.openwall.com>
CC: <yan.li.cn@...driver.com>
Subject: [PATCH] add check for pthread_attr_setschedparam().
From: Yan Li <yan.li.cn@...driver.com>
---
src/thread/pthread_attr_setschedparam.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
mode change 100644 => 100755 src/thread/pthread_attr_setschedparam.c
diff --git a/src/thread/pthread_attr_setschedparam.c b/src/thread/pthread_attr_setschedparam.c
old mode 100644
new mode 100755
index d4c1204f..4e28415e
--- a/src/thread/pthread_attr_setschedparam.c
+++ b/src/thread/pthread_attr_setschedparam.c
@@ -2,6 +2,13 @@
int pthread_attr_setschedparam(pthread_attr_t *restrict a, const struct sched_param *restrict param)
{
- a->_a_prio = param->sched_priority;
- return 0;
+ int min = sched_get_priority_min (a->_a_policy);
+ int max = sched_get_priority_max (a->_a_policy);
+
+ if (min < 0 || max < 0 || param->sched_priority < min || param->sched_priority > max){
+ return EINVAL;
+ }
+
+ a->_a_prio = param->sched_priority;
+ return 0;
}
--
2.34.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.