From 518435f376fb7b1a1972ea44cd932f1314f34cbf Mon Sep 17 00:00:00 2001 From: Isaac Dunham Date: Sat, 26 Mar 2016 21:37:36 -0700 Subject: [PATCH] Use strsignal() instead of sys_siglist[]. musl libc only implements strsignal(). POSIX 2008 requires strsignal() but not sys_siglist[], and glibc, the BSDs, Solaris, and OS X support both. I'm not sure about the status on mingw; as far as I can tell, they define strsignal(x) as sys_siglist[x]. Also use snprintf() because it's not strictly guaranteed that signal descriptions be any particular length. I'm not aware of any signal descriptions over 114 bytes long, so this is mostly paranoia. --- utest/ctest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utest/ctest.h b/utest/ctest.h index a62103f..1deea32 100644 --- a/utest/ctest.h +++ b/utest/ctest.h @@ -637,7 +637,7 @@ static void *find_symbol(struct ctest *test, const char *fname) static void sighandler(int signum) { char msg[128]; - sprintf(msg, "[SIGNAL %d: %s]", signum, sys_siglist[signum]); + snprintf(msg, sizeof(msg), "[SIGNAL %d: %s]", signum, strsignal(signum)); color_print(ANSI_BRED, msg); fflush(stdout); -- 2.7.4