From 149a3464ef35fbaa98c57e2775a7a4ab20c2ee75 Mon Sep 17 00:00:00 2001 From: Steve Grubb Date: Sun, 5 Nov 2023 14:24:49 -0500 Subject: [PATCH] fix the use of isdigit everywhere Reference:https://github.com/linux-audit/audit-userspace/commit/149a3464ef35fbaa98c57e2775a7a4ab20c2ee75 Conflict:audisp/plugins/af_unix/audisp-af_unix.c,src/ausearch-options.c --- audisp/plugins/ids/ids_config.c | 2 +- audisp/plugins/remote/remote-config.c | 2 +- audisp/plugins/zos-remote/zos-remote-config.c | 6 ++-- auparse/auditd-config.c | 2 +- auparse/interpret.c | 6 ++-- src/auditctl.c | 6 ++-- src/aureport-options.c | 4 +-- src/aureport-output.c | 2 +- src/ausearch-options.c | 36 +++++++++---------- src/ausearch-parse.c | 2 +- tools/ausyscall/ausyscall.c | 4 +-- 11 files changed, 36 insertions(+), 36 deletions(-) diff --git a/audisp/plugins/ids/ids_config.c b/audisp/plugins/ids/ids_config.c index 4da5ca9..f773794 100644 --- a/audisp/plugins/ids/ids_config.c +++ b/audisp/plugins/ids/ids_config.c @@ -345,7 +345,7 @@ static int unsigned_int_parser(struct nv_pair *nv, int line, unsigned int *val) /* check that all chars are numbers */ for (i=0; ptr[i]; i++) { - if (!isdigit(ptr[i])) { + if (!isdigit((unsigned char)ptr[i])) { syslog(LOG_ERR, "Value %s should only be numbers - line %d", nv->value, line); diff --git a/audisp/plugins/remote/remote-config.c b/audisp/plugins/remote/remote-config.c index 7d80752..1f05cdd 100644 --- a/audisp/plugins/remote/remote-config.c +++ b/audisp/plugins/remote/remote-config.c @@ -484,7 +484,7 @@ static int parse_uint (const struct nv_pair *nv, int line, unsigned int *valp, /* check that all chars are numbers */ for (i=0; ptr[i]; i++) { - if (!isdigit(ptr[i])) { + if (!isdigit((unsigned char)ptr[i])) { syslog(LOG_ERR, "Value %s should only be numbers - line %d", nv->value, line); diff --git a/audisp/plugins/zos-remote/zos-remote-config.c b/audisp/plugins/zos-remote/zos-remote-config.c index b92dc77..2f7e42f 100644 --- a/audisp/plugins/zos-remote/zos-remote-config.c +++ b/audisp/plugins/zos-remote/zos-remote-config.c @@ -301,7 +301,7 @@ static int port_parser(struct nv_pair *nv, int line, plugin_conf_t * c) /* check that all chars are numbers */ for (i = 0; ptr[i]; i++) { - if (!isdigit(ptr[i])) { + if (!isdigit((unsigned char)ptr[i])) { log_err("Value %s should only be numbers - line %d", nv->value, line); return 1; } @@ -327,7 +327,7 @@ static int timeout_parser(struct nv_pair *nv, int line, plugin_conf_t * c) /* check that all chars are numbers */ for (i = 0; ptr[i]; i++) { - if (!isdigit(ptr[i])) { + if (!isdigit((unsigned char)ptr[i])) { log_err("Value %s should only be numbers - line %d", nv->value, line); return 1; } @@ -376,7 +376,7 @@ static int q_depth_parser(struct nv_pair *nv, int line, plugin_conf_t * c) /* check that all chars are numbers */ for (i = 0; ptr[i]; i++) { - if (!isdigit(ptr[i])) { + if (!isdigit((unsigned char)ptr[i])) { log_err("Value %s should only be numbers - line %d", nv->value, line); return 1; } diff --git a/auparse/auditd-config.c b/auparse/auditd-config.c index bdb9cf8..d0fa746 100644 --- a/auparse/auditd-config.c +++ b/auparse/auditd-config.c @@ -341,7 +341,7 @@ static int eoe_timeout_parser(auparse_state_t *au, const char *val, int line, /* check that all chars are numbers */ for (i=0; ptr[i]; i++) { - if (!isdigit(ptr[i])) { + if (!isdigit((unsigned char)ptr[i])) { audit_msg(au, LOG_ERR, "Value %s should only be numbers - line %d", val, line); diff --git a/auparse/interpret.c b/auparse/interpret.c index 84c41ea..cc03a15 100644 --- a/auparse/interpret.c +++ b/auparse/interpret.c @@ -321,7 +321,7 @@ static void key_escape(const char *orig, char *dest, auparse_esc_t escape_mode) static int is_int_string(const char *str) { while (*str) { - if (!isdigit(*str)) + if (!isdigit((unsigned char)*str)) return 0; str++; } @@ -1381,7 +1381,7 @@ static const char *print_success(const char *val) { int res; - if (isdigit(*val)) { + if (isdigit((unsigned char)*val)) { errno = 0; res = strtoul(val, NULL, 10); if (errno) { @@ -2185,7 +2185,7 @@ static const char *print_fanotify(const char *val) { int res; - if (isdigit(*val)) { + if (isdigit((unsigned char)*val)) { errno = 0; res = strtoul(val, NULL, 10); if (errno) { diff --git a/src/auditctl.c b/src/auditctl.c index 1eb424c..778b374 100644 --- a/src/auditctl.c +++ b/src/auditctl.c @@ -631,7 +631,7 @@ static int setopt(int count, int lineno, char *vars[]) } break; case 'r': - if (optarg && isdigit(optarg[0])) { + if (optarg && isdigit((unsigned char)optarg[0])) { uint32_t rate; errno = 0; rate = strtoul(optarg,NULL,0); @@ -650,7 +650,7 @@ static int setopt(int count, int lineno, char *vars[]) } break; case 'b': - if (optarg && isdigit(optarg[0])) { + if (optarg && isdigit((unsigned char)optarg[0])) { uint32_t limit; errno = 0; limit = strtoul(optarg,NULL,0); @@ -1061,7 +1061,7 @@ process_keys: case 2: #if HAVE_DECL_AUDIT_VERSION_BACKLOG_WAIT_TIME == 1 || \ HAVE_DECL_AUDIT_STATUS_BACKLOG_WAIT_TIME == 1 - if (optarg && isdigit(optarg[0])) { + if (optarg && isdigit((unsigned char)optarg[0])) { uint32_t bwt; errno = 0; bwt = strtoul(optarg,NULL,0); diff --git a/src/aureport-options.c b/src/aureport-options.c index 7a8d92a..7264d5e 100644 --- a/src/aureport-options.c +++ b/src/aureport-options.c @@ -384,7 +384,7 @@ int check_params(int count, char *vars[]) // } else { // UNIMPLEMENTED; // set_detail(D_SPECIFIC); -// if (isdigit(optarg[0])) { +// if (isdigit((unsigned char)optarg[0])) { // errno = 0; // event_id = strtoul(optarg, // NULL, 10); @@ -763,7 +763,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; arg_eoe_timeout = (time_t)strtoul(optarg, NULL, 10); if (errno || arg_eoe_timeout == 0) { diff --git a/src/aureport-output.c b/src/aureport-output.c index a635d53..27a2ce2 100644 --- a/src/aureport-output.c +++ b/src/aureport-output.c @@ -976,7 +976,7 @@ static void do_user_summary_output(slist *sptr) long uid; char name[64]; - if (sn->str[0] == '-' || isdigit(sn->str[0])) { + if (sn->str[0] == '-' || isdigit((unsigned char)sn->str[0])) { uid = strtol(sn->str, NULL, 10); printf("%u ", sn->hits); safe_print_string(aulookup_uid(uid, name, diff --git a/src/ausearch-options.c b/src/ausearch-options.c index eff0596..aa13590 100644 --- a/src/ausearch-options.c +++ b/src/ausearch-options.c @@ -253,7 +253,7 @@ static int convert_str_to_msg(const char *optarg) { int tmp, retval = 0; - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; tmp = strtoul(optarg, NULL, 10); if (errno) { @@ -335,7 +335,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_id = strtoul(optarg, NULL, 10); if (errno) { @@ -357,7 +357,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; arg_eoe_timeout = (time_t)strtoul(optarg, NULL, 10); if (errno || arg_eoe_timeout == 0) { @@ -463,7 +463,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_gid = strtoul(optarg,NULL,10); if (errno) { @@ -497,7 +497,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_egid = strtoul(optarg,NULL,10); if (errno) { @@ -529,7 +529,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_gid = strtoul(optarg,NULL,10); if (errno) { @@ -648,7 +648,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_ppid = strtol(optarg,NULL,10); if (errno) @@ -669,7 +669,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_pid = strtol(optarg,NULL,10); if (errno) @@ -787,7 +787,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_syscall = (int)strtoul(optarg, NULL, 10); if (errno) { @@ -886,7 +886,7 @@ int check_params(int count, char *vars[]) } { size_t len = strlen(optarg); - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; unsigned long optval = strtoul(optarg,NULL,10); if (errno || optval >= (1ul << 32)) @@ -894,7 +894,7 @@ int check_params(int count, char *vars[]) event_session_id = optval; c++; } else if (len >= 2 && *(optarg)=='-' && - (isdigit(optarg[1]))) { + (isdigit((unsigned char)optarg[1]))) { errno = 0; long optval = strtol(optarg, NULL, 0); if (errno || optval < INT_MIN || optval > INT_MAX) { @@ -926,7 +926,7 @@ int check_params(int count, char *vars[]) } { size_t len = strlen(optarg); - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_exit = strtoll(optarg, NULL, 0); if (errno) { @@ -935,7 +935,7 @@ int check_params(int count, char *vars[]) optarg); } } else if (len >= 2 && *(optarg)=='-' && - (isdigit(optarg[1]))) { + (isdigit((unsigned char)optarg[1]))) { errno = 0; event_exit = strtoll(optarg, NULL, 0); if (errno) { @@ -1067,7 +1067,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_uid = strtoul(optarg,NULL,10); if (errno) { @@ -1100,7 +1100,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_euid = strtoul(optarg,NULL,10); if (errno) { @@ -1133,7 +1133,7 @@ int check_params(int count, char *vars[]) retval = -1; break; } - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_uid = strtoul(optarg,NULL,10); if (errno) { @@ -1177,7 +1177,7 @@ int check_params(int count, char *vars[]) } { size_t len = strlen(optarg); - if (isdigit(optarg[0])) { + if (isdigit((unsigned char)optarg[0])) { errno = 0; event_loginuid = strtoul(optarg,NULL,10); if (errno) { @@ -1187,7 +1187,7 @@ int check_params(int count, char *vars[]) retval = -1; } } else if (len >= 2 && *(optarg)=='-' && - (isdigit(optarg[1]))) { + (isdigit((unsigned char)optarg[1]))) { errno = 0; event_loginuid = strtol(optarg, NULL, 0); if (errno) { diff --git a/src/ausearch-parse.c b/src/ausearch-parse.c index 7ee7bd4..f34e21d 100644 --- a/src/ausearch-parse.c +++ b/src/ausearch-parse.c @@ -1115,7 +1115,7 @@ try_again: return 25; ptr = str + 4; term = ptr; - while (isdigit(*term)) + while (isdigit((unsigned char)*term)) term++; if (term == ptr) return 14; diff --git a/tools/ausyscall/ausyscall.c b/tools/ausyscall/ausyscall.c index 206e9ff..2ef4ad1 100644 --- a/tools/ausyscall/ausyscall.c +++ b/tools/ausyscall/ausyscall.c @@ -47,9 +47,9 @@ int main(int argc, char *argv[]) usage(); } else if (argc < 2) usage(); - + for (i=1; i