aboutsummaryrefslogtreecommitdiff
path: root/modules/pam_time
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2023-08-07 12:46:40 +0200
committerDmitry V. Levin <ldv@strace.io>2023-08-07 10:46:40 +0000
commit43abfff43537092e20bc129f8208d082e73aff1a (patch)
tree0a474a6ecf44fd9b0090d75f0f528fb9b55e62ce /modules/pam_time
parent4020ca8c0fe3ac88eccc5c62aa8d8c63a4043578 (diff)
downloadpam-43abfff43537092e20bc129f8208d082e73aff1a.tar.gz
pam-43abfff43537092e20bc129f8208d082e73aff1a.tar.bz2
pam-43abfff43537092e20bc129f8208d082e73aff1a.zip
modules: cast to unsigned char for character handling function
Character handling functions, like isspace(3), expect a value representable as unsigned char or equal to EOF. Otherwise the behavior is undefined. See https://wiki.sei.cmu.edu/confluence/display/c/STR37-C.+Arguments+to+character-handling+functions+must+be+representable+as+an+unsigned+char
Diffstat (limited to 'modules/pam_time')
-rw-r--r--modules/pam_time/pam_time.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/modules/pam_time/pam_time.c b/modules/pam_time/pam_time.c
index 6b7adefc..af276059 100644
--- a/modules/pam_time/pam_time.c
+++ b/modules/pam_time/pam_time.c
@@ -286,7 +286,7 @@ logic_member(const char *string, int *at)
break;
default:
- if (isalpha(c) || c == '*' || isdigit(c) || c == '_'
+ if (isalpha((unsigned char)c) || c == '*' || isdigit((unsigned char)c) || c == '_'
|| c == '-' || c == '.' || c == '/' || c == ':') {
token = 1;
} else if (token) {
@@ -319,7 +319,7 @@ logic_field(pam_handle_t *pamh, const void *me, const char *x, int rule,
if (next == VAL) {
if (c == '!')
not = !not;
- else if (isalpha(c) || c == '*' || isdigit(c) || c == '_'
+ else if (isalpha((unsigned char)c) || c == '*' || isdigit((unsigned char)c) || c == '_'
|| c == '-' || c == '.' || c == '/' || c == ':') {
right = not ^ agrees(pamh, me, x+at, l, rule);
if (oper == AND)
@@ -449,13 +449,13 @@ check_time(pam_handle_t *pamh, const void *AT, const char *times,
not = FALSE;
}
- for (marked_day = 0; len > 0 && isalpha(times[j]); --len) {
+ for (marked_day = 0; len > 0 && isalpha((unsigned char)times[j]); --len) {
int this_day=-1;
D(("%c%c ?", times[j], times[j+1]));
for (i=0; days[i].d != NULL; ++i) {
- if (tolower(times[j]) == days[i].d[0]
- && tolower(times[j+1]) == days[i].d[1] ) {
+ if (tolower((unsigned char)times[j]) == days[i].d[0]
+ && tolower((unsigned char)times[j+1]) == days[i].d[1] ) {
this_day = days[i].bit;
break;
}
@@ -474,7 +474,7 @@ check_time(pam_handle_t *pamh, const void *AT, const char *times,
D(("day range = 0%o", marked_day));
time_start = 0;
- for (i=0; len > 0 && i < 4 && isdigit(times[i+j]); ++i, --len) {
+ for (i=0; len > 0 && i < 4 && isdigit((unsigned char)times[i+j]); ++i, --len) {
time_start *= 10;
time_start += times[i+j]-'0'; /* is this portable? */
}
@@ -482,7 +482,7 @@ check_time(pam_handle_t *pamh, const void *AT, const char *times,
if (times[j] == '-') {
time_end = 0;
- for (i=1; len > 0 && i < 5 && isdigit(times[i+j]); ++i, --len) {
+ for (i=1; len > 0 && i < 5 && isdigit((unsigned char)times[i+j]); ++i, --len) {
time_end *= 10;
time_end += times[i+j]-'0'; /* is this portable */
}