From: Eugene Syromyatnikov Date: Sun, 7 Oct 2018 03:25:33 +0000 (+0200) Subject: signal: return NULL if signal number has no string representation X-Git-Tag: v4.26~39 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b84c24551d89df173e32dd517c2716cfcf9b5a0;p=strace signal: return NULL if signal number has no string representation 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 --- diff --git a/signal.c b/signal.c index 8dacd895..660790be 100644 --- 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 *