From 9a75519edc6054603e3fbcac623c82afee8d5a4f Mon Sep 17 00:00:00 2001 From: chenrun1 Date: Wed, 25 Sep 2024 17:35:30 +0800 Subject: [PATCH] timer_create:Checks whether the signo provided by the user is valid Summary: When the user sets an illegal signo, the error will only be known when timer_signotify is triggered during timeout. By intercepting timer_create, we can directly locate the problem Signed-off-by: chenrun1 --- sched/timer/timer_create.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sched/timer/timer_create.c b/sched/timer/timer_create.c index 40016f8fe6..57b9800bc3 100644 --- a/sched/timer/timer_create.c +++ b/sched/timer/timer_create.c @@ -164,7 +164,9 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp, /* Sanity checks. */ if (timerid == NULL || (clockid != CLOCK_REALTIME && - clockid != CLOCK_MONOTONIC && clockid != CLOCK_BOOTTIME)) + clockid != CLOCK_MONOTONIC && clockid != CLOCK_BOOTTIME) || + (evp != NULL && evp->sigev_notify == SIGEV_SIGNAL && + !GOOD_SIGNO(evp->sigev_signo))) { set_errno(EINVAL); return ERROR;