fix rejection of dns responses with pointers past 512 byte offset
[musl] / src / string / strsignal.c
index f0c3db7..5156366 100644 (file)
@@ -1,5 +1,6 @@
 #include <signal.h>
 #include <string.h>
+#include "locale_impl.h"
 
 #if (SIGHUP == 1) && (SIGINT == 2) && (SIGQUIT == 3) && (SIGILL == 4) \
  && (SIGTRAP == 5) && (SIGABRT == 6) && (SIGBUS == 7) && (SIGFPE == 8) \
@@ -30,7 +31,11 @@ static const char map[] = {
        [SIGPIPE]   = 13,
        [SIGALRM]   = 14,
        [SIGTERM]   = 15,
+#if defined(SIGSTKFLT)
        [SIGSTKFLT] = 16,
+#elif defined(SIGEMT)
+       [SIGEMT]    = 16,
+#endif
        [SIGCHLD]   = 17,
        [SIGCONT]   = 18,
        [SIGSTOP]   = 19,
@@ -61,7 +66,7 @@ static const char strings[] =
        "Trace/breakpoint trap\0"
        "Aborted\0"
        "Bus error\0"
-       "Floating point exception\0"
+       "Arithmetic exception\0"
        "Killed\0"
        "User defined signal 1\0"
        "Segmentation fault\0"
@@ -69,8 +74,14 @@ static const char strings[] =
        "Broken pipe\0"
        "Alarm clock\0"
        "Terminated\0"
+#if defined(SIGSTKFLT)
        "Stack fault\0"
-       "Child exited\0"
+#elif defined(SIGEMT)
+       "Emulator trap\0"
+#else
+       "Unknown signal\0"
+#endif
+       "Child process status\0"
        "Continued\0"
        "Stopped (signal)\0"
        "Stopped\0"
@@ -104,12 +115,12 @@ static const char strings[] =
 
 char *strsignal(int signum)
 {
-       char *s = (char *)strings;
+       const char *s = strings;
 
        signum = sigmap(signum);
        if (signum - 1U >= _NSIG-1) signum = 0;
 
        for (; signum--; s++) for (; *s; s++);
 
-       return s;
+       return (char *)LCTRANS_CUR(s);
 }