From 43abfff43537092e20bc129f8208d082e73aff1a Mon Sep 17 00:00:00 2001 From: Christian Göttsche Date: Mon, 7 Aug 2023 12:46:40 +0200 Subject: 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 --- modules/pam_limits/pam_limits.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules/pam_limits') diff --git a/modules/pam_limits/pam_limits.c b/modules/pam_limits/pam_limits.c index 8b1755b7..cc41435f 100644 --- a/modules/pam_limits/pam_limits.c +++ b/modules/pam_limits/pam_limits.c @@ -852,7 +852,7 @@ parse_config_file(pam_handle_t *pamh, const char *uname, uid_t uid, gid_t gid, line = buf; /* skip the leading white space */ - while (*line && isspace(*line)) + while (*line && isspace((unsigned char)*line)) line++; /* Rip off the comments */ @@ -874,7 +874,7 @@ parse_config_file(pam_handle_t *pamh, const char *uname, uid_t uid, gid_t gid, i, domain, ltype, item, value)); for(j=0; j < strlen(ltype); j++) - ltype[j]=tolower(ltype[j]); + ltype[j]=tolower((unsigned char)ltype[j]); if ((rngtype=parse_uid_range(pamh, domain, &min_uid, &max_uid)) < 0) { pam_syslog(pamh, LOG_WARNING, "invalid uid range '%s' - skipped", domain); @@ -883,9 +883,9 @@ parse_config_file(pam_handle_t *pamh, const char *uname, uid_t uid, gid_t gid, if (i == 4) { /* a complete line */ for(j=0; j < strlen(item); j++) - item[j]=tolower(item[j]); + item[j]=tolower((unsigned char)item[j]); for(j=0; j < strlen(value); j++) - value[j]=tolower(value[j]); + value[j]=tolower((unsigned char)value[j]); if (strcmp(uname, domain) == 0) /* this user have a limit */ process_limit(pamh, LIMITS_DEF_USER, ltype, item, value, ctrl, pl); -- cgit v1.2.3