diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2023-08-07 12:46:40 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-08-07 10:46:40 +0000 |
commit | 43abfff43537092e20bc129f8208d082e73aff1a (patch) | |
tree | 0a474a6ecf44fd9b0090d75f0f528fb9b55e62ce /modules/pam_group | |
parent | 4020ca8c0fe3ac88eccc5c62aa8d8c63a4043578 (diff) | |
download | pam-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_group')
-rw-r--r-- | modules/pam_group/pam_group.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/modules/pam_group/pam_group.c b/modules/pam_group/pam_group.c index 6877849e..2525e048 100644 --- a/modules/pam_group/pam_group.c +++ b/modules/pam_group/pam_group.c @@ -232,7 +232,7 @@ static int 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) { @@ -266,7 +266,7 @@ logic_field (const pam_handle_t *pamh, const void *me, 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) @@ -394,13 +394,13 @@ check_time (const pam_handle_t *pamh, const void *AT, 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; } @@ -419,7 +419,7 @@ check_time (const pam_handle_t *pamh, const void *AT, 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? */ } @@ -427,7 +427,7 @@ check_time (const pam_handle_t *pamh, const void *AT, 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? */ } @@ -497,7 +497,7 @@ static int find_member(const char *string, int *at) break; default: - if (isalpha(c) || isdigit(c) || c == '_' || c == '*' + if (isalpha((unsigned char)c) || isdigit((unsigned char)c) || c == '_' || c == '*' || c == '-') { token = 1; } else if (token) { |