From: <yan.li.cn@windriver.com>
To: <musl@lists.openwall.com>
Cc: <yan.li.cn@windriver.com>
Subject: [musl] [PATCH] add check for pthread_attr_setschedparam().
Date: Tue, 24 Dec 2024 10:03:01 +0800 [thread overview]
Message-ID: <20241224020301.1673274-1-yan.li.cn@windriver.com> (raw)
From: Yan Li <yan.li.cn@windriver.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
next reply other threads:[~2024-12-24 2:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-24 2:03 yan.li.cn [this message]
2024-12-24 9:41 ` Rich Felker
2024-12-24 14:00 ` Markus Wichmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241224020301.1673274-1-yan.li.cn@windriver.com \
--to=yan.li.cn@windriver.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).