diff --git a/src/chage.c b/src/chage.c index 9b85b425a..4b482be7a 100644 --- a/src/chage.c +++ b/src/chage.c @@ -26,7 +26,7 @@ #endif /* ACCT_TOOLS_SETUID */ #include -#include "atoi/str2i.h" +#include "atoi/a2i.h" #include "defines.h" #include "memzero.h" #include "prototypes.h" @@ -171,17 +171,13 @@ static int new_fields (void) SNPRINTF(buf, "%ld", mindays); change_field (buf, sizeof buf, _("Minimum Password Age")); - if ( (str2sl(&mindays, buf) == -1) - || (mindays < -1)) { + if (a2sl(&mindays, buf, NULL, 0, -1, LONG_MAX) == -1) return 0; - } SNPRINTF(buf, "%ld", maxdays); change_field (buf, sizeof buf, _("Maximum Password Age")); - if ( (str2sl(&maxdays, buf) == -1) - || (maxdays < -1)) { + if (a2sl(&maxdays, buf, NULL, 0, -1, LONG_MAX) == -1) return 0; - } if (-1 == lstchgdate || lstchgdate > LONG_MAX / DAY) strcpy(buf, "-1"); @@ -201,17 +197,13 @@ static int new_fields (void) SNPRINTF(buf, "%ld", warndays); change_field (buf, sizeof buf, _("Password Expiration Warning")); - if ( (str2sl(&warndays, buf) == -1) - || (warndays < -1)) { + if (a2sl(&warndays, buf, NULL, 0, -1, LONG_MAX) == -1) return 0; - } SNPRINTF(buf, "%ld", inactdays); change_field (buf, sizeof buf, _("Password Inactive")); - if ( (str2sl(&inactdays, buf) == -1) - || (inactdays < -1)) { + if (a2sl(&inactdays, buf, NULL, 0, -1, LONG_MAX) == -1) return 0; - } if (-1 == expdate || LONG_MAX / DAY < expdate) strcpy(buf, "-1"); @@ -397,8 +389,7 @@ static void process_flags (int argc, char **argv) break; case 'I': Iflg = true; - if ( (str2sl(&inactdays, optarg) == -1) - || (inactdays < -1)) { + if (a2sl(&inactdays, optarg, NULL, 0, -1, LONG_MAX) == -1) { fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg); @@ -410,8 +401,7 @@ static void process_flags (int argc, char **argv) break; case 'm': mflg = true; - if ( (str2sl(&mindays, optarg) == -1) - || (mindays < -1)) { + if (a2sl(&mindays, optarg, NULL, 0, -1, LONG_MAX) == -1) { fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg); @@ -420,8 +410,7 @@ static void process_flags (int argc, char **argv) break; case 'M': Mflg = true; - if ( (str2sl(&maxdays, optarg) == -1) - || (maxdays < -1)) { + if (a2sl(&maxdays, optarg, NULL, 0, -1, LONG_MAX) == -1) { fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg); @@ -434,8 +423,7 @@ static void process_flags (int argc, char **argv) break; case 'W': Wflg = true; - if ( (str2sl(&warndays, optarg) == -1) - || (warndays < -1)) { + if (a2sl(&warndays, optarg, NULL, 0, -1, LONG_MAX) == -1) { fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg);