From 2b84c24551d89df173e32dd517c2716cfcf9b5a0 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Sun, 7 Oct 2018 05:25:33 +0200 Subject: [PATCH] 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 --- signal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 * -- 2.50.1