Lines 1-7
Link Here
|
1 |
/* |
1 |
/* |
2 |
* SPDX-License-Identifier: ISC |
2 |
* SPDX-License-Identifier: ISC |
3 |
* |
3 |
* |
4 |
* Copyright (c) 2012-2015, 2017-2019 Todd C. Miller <Todd.Miller@sudo.ws> |
4 |
* Copyright (c) 2012-2015, 2017-2020 Todd C. Miller <Todd.Miller@sudo.ws> |
5 |
* |
5 |
* |
6 |
* Permission to use, copy, modify, and distribute this software for any |
6 |
* Permission to use, copy, modify, and distribute this software for any |
7 |
* purpose with or without fee is hereby granted, provided that the above |
7 |
* purpose with or without fee is hereby granted, provided that the above |
Lines 32-51
Link Here
|
32 |
#include <unistd.h> |
32 |
#include <unistd.h> |
33 |
|
33 |
|
34 |
#include "sudo_compat.h" |
34 |
#include "sudo_compat.h" |
|
|
35 |
#include "sudo_util.h" |
35 |
|
36 |
|
36 |
#if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1 |
37 |
#if !defined(HAVE_SIGABBREV_NP) |
37 |
# define sudo_sys_signame sys_signame |
38 |
# if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1 |
38 |
#elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1 |
39 |
# define sigabbrev_np(_x) sys_signame[(_x)] |
39 |
# define sudo_sys_signame _sys_signame |
40 |
# elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1 |
40 |
#elif defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 1 |
41 |
# define sigabbrev_np(_x) _sys_signame[(_x)] |
41 |
# define sudo_sys_signame sys_sigabbrev |
42 |
# elif defined(HAVE_SYS_SIGABBREV) |
42 |
#else |
43 |
# define sigabbrev_np(_x) sys_sigabbrev[(_x)] |
43 |
# ifdef HAVE_SYS_SIGABBREV |
44 |
# if defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 0 |
44 |
/* sys_sigabbrev is not declared by glibc */ |
45 |
/* sys_sigabbrev is not declared by glibc */ |
45 |
# define sudo_sys_signame sys_sigabbrev |
46 |
extern const char *const sys_sigabbrev[NSIG]; |
|
|
47 |
# endif |
48 |
# else |
49 |
# define sigabbrev_np(_x) sudo_sys_signame[(_x)] |
50 |
extern const char *const sudo_sys_signame[NSIG]; |
46 |
# endif |
51 |
# endif |
47 |
extern const char *const sudo_sys_signame[NSIG]; |
52 |
#endif /* !HAVE_SIGABBREV_NP */ |
48 |
#endif |
|
|
49 |
|
53 |
|
50 |
/* |
54 |
/* |
51 |
* Translate signal number to name. |
55 |
* Translate signal number to name. |
Lines 77-91
Link Here
|
77 |
return 0; |
81 |
return 0; |
78 |
} |
82 |
} |
79 |
#endif |
83 |
#endif |
80 |
if (signo > 0 && signo < NSIG && sudo_sys_signame[signo] != NULL) { |
84 |
if (signo > 0 && signo < NSIG) { |
81 |
strlcpy(signame, sudo_sys_signame[signo], SIG2STR_MAX); |
85 |
const char *cp = sigabbrev_np(signo); |
82 |
/* Make sure we always return an upper case signame. */ |
86 |
if (cp != NULL) { |
83 |
if (islower((unsigned char)signame[0])) { |
87 |
strlcpy(signame, cp, SIG2STR_MAX); |
84 |
int i; |
88 |
/* Make sure we always return an upper case signame. */ |
85 |
for (i = 0; signame[i] != '\0'; i++) |
89 |
if (islower((unsigned char)signame[0])) { |
86 |
signame[i] = toupper((unsigned char)signame[i]); |
90 |
int i; |
|
|
91 |
for (i = 0; signame[i] != '\0'; i++) |
92 |
signame[i] = toupper((unsigned char)signame[i]); |
93 |
} |
94 |
return 0; |
87 |
} |
95 |
} |
88 |
return 0; |
|
|
89 |
} |
96 |
} |
90 |
errno = EINVAL; |
97 |
errno = EINVAL; |
91 |
return -1; |
98 |
return -1; |