prevent CNAME/PTR parsing from reading data past the response end
[musl] / src / signal / raise.c
index f437d23..f051201 100644 (file)
@@ -1,18 +1,13 @@
 #include <signal.h>
-#include <errno.h>
+#include <stdint.h>
 #include "syscall.h"
+#include "pthread_impl.h"
 
 int raise(int sig)
 {
-       int pid, tid, ret;
-       /* Getting the pid/tid pair is not atomic, and could give wrong
-        * result if a fork occurs in a signal handler between the two
-        * syscalls. Use the tgkill syscall's ESRCH semantics to detect
-        * this condition and retry. */
-       do {
-               tid = syscall0(__NR_gettid);
-               pid = syscall0(__NR_getpid);
-               ret = syscall3(__NR_tgkill, pid, tid, sig);
-       } while (ret<0 && errno == ESRCH);
+       sigset_t set;
+       __block_app_sigs(&set);
+       int ret = syscall(SYS_tkill, __pthread_self()->tid, sig);
+       __restore_sigs(&set);
        return ret;
 }