diff options
author | Trumeet <yuuta@yuuta.moe> | 2021-11-13 17:38:25 -0800 |
---|---|---|
committer | Trumeet <yuuta@yuuta.moe> | 2021-11-13 17:38:25 -0800 |
commit | beb557ae8510369e762bd25fe7c4b7a013ed0ca5 (patch) | |
tree | e2121c75658b459553a80f7282a8ad506ab54ba8 | |
parent | 05849372aa0e03e465daba65827f6b8f7c22c5c5 (diff) | |
download | mutebot-beb557ae8510369e762bd25fe7c4b7a013ed0ca5.tar mutebot-beb557ae8510369e762bd25fe7c4b7a013ed0ca5.tar.gz mutebot-beb557ae8510369e762bd25fe7c4b7a013ed0ca5.tar.bz2 mutebot-beb557ae8510369e762bd25fe7c4b7a013ed0ca5.zip |
fix: stack-buffer-overflow for sigset_t
-rw-r--r-- | tdutils.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -44,14 +44,18 @@ bool closing = false; static bool sighandler_setup = false; static pthread_t thread_sighandler; +/** + * Used for sigwait(2). + */ +sigset_t set; + static void *main_sighandler(void *arg) { pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); int r; - sigset_t *set = arg; int sig; while (true) { - r = sigwait(set, &sig); + r = sigwait(&set, &sig); if (r) { fprintf(stderr, "Cannot call sigwait(): %d.\n", r); goto cleanup; @@ -72,7 +76,6 @@ static void *main_sighandler(void *arg) { static int sighandler_init() { int r; - sigset_t set; sigemptyset(&set); sigaddset(&set, SIGTERM); sigaddset(&set, SIGINT); @@ -82,7 +85,7 @@ static int sighandler_init() { fprintf(stderr, "Cannot call pthread_sigmask(): %d\n", r); goto cleanup; } - r = pthread_create(&thread_sighandler, NULL, &main_sighandler, &set); + r = pthread_create(&thread_sighandler, NULL, &main_sighandler, NULL); if (r) { fprintf(stderr, "Cannot call pthread_create(): %d\n", r); goto cleanup; |