From: Todd C. Miller Date: Mon, 19 Aug 2019 20:25:05 +0000 (-0600) Subject: sys_signame on macOS contains lower-cases names X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b98b82e4a2d8ba313819c3c4968d69694cd0ecf1;p=sudo sys_signame on macOS contains lower-cases names --- diff --git a/lib/util/sig2str.c b/lib/util/sig2str.c index 6049b1b2c..acd7d0f51 100644 --- a/lib/util/sig2str.c +++ b/lib/util/sig2str.c @@ -36,6 +36,7 @@ #ifdef HAVE_STRINGS_H # include #endif /* HAVE_STRINGS_H */ +#include #include #include @@ -83,6 +84,12 @@ sudo_sig2str(int signo, char *signame) #endif if (signo > 0 && signo < NSIG && sudo_sys_signame[signo] != NULL) { strlcpy(signame, sudo_sys_signame[signo], SIG2STR_MAX); + /* Make sure we always return an upper case signame. */ + if (islower((unsigned char)signame[0])) { + int i; + for (i = 0; signame[i] != '\0'; i++) + signame[i] = toupper((unsigned char)signame[i]); + } return 0; } errno = EINVAL; diff --git a/lib/util/str2sig.c b/lib/util/str2sig.c index 63ea642cc..fd0052387 100644 --- a/lib/util/str2sig.c +++ b/lib/util/str2sig.c @@ -154,7 +154,8 @@ sudo_str2sig(const char *signame, int *result) /* Check sys_signame[]. */ for (signo = 1; signo < NSIG; signo++) { if (sudo_sys_signame[signo] != NULL) { - if (strcmp(signame, sudo_sys_signame[signo]) == 0) { + /* On macOS sys_signame[] may contain lower-case names. */ + if (strcasecmp(signame, sudo_sys_signame[signo]) == 0) { *result = signo; return 0; }