]> granicus.if.org Git - strace/commitdiff
signal: return NULL if signal number has no string representation
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 7 Oct 2018 03:25:33 +0000 (05:25 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 17 Dec 2018 19:19:23 +0000 (19:19 +0000)
Also return NULL if signal number is 0.

* signal.c (signame): Return NULL if signal name has not been found.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
signal.c

index 8dacd89543a89be507a98530e705d260770053c5..660790be1ff0a0ad16b728a3861f9240a1be7797 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -105,22 +105,22 @@ print_sa_handler(kernel_ulong_t handler)
 const char *
 signame(const int sig)
 {
-       static char buf[sizeof("SIGRT_%u") + sizeof(int)*3];
-
-       if (sig >= 0) {
+       if (sig > 0) {
                const unsigned int s = sig;
 
                if (s < nsignals)
                        return signalent[s];
 #ifdef ASM_SIGRTMAX
                if (s >= ASM_SIGRTMIN && s <= (unsigned int) ASM_SIGRTMAX) {
+                       static char buf[sizeof("SIGRT_%u") + sizeof(s) * 3];
+
                        xsprintf(buf, "SIGRT_%u", s - ASM_SIGRTMIN);
                        return buf;
                }
 #endif
        }
-       xsprintf(buf, "%d", sig);
-       return buf;
+
+       return NULL;
 }
 
 const char *