From: Alejandro Colomar Date: Tue, 9 Jan 2024 20:21:00 +0000 (+0100) Subject: src/passwd.c: Simplify, by calling a2sl() instead of str2sl() X-Git-Tag: 4.17.0-rc1~153 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e341291f99f9a984304e70d11ac161f5e6fa71c8;p=thirdparty%2Fshadow.git src/passwd.c: Simplify, by calling a2sl() instead of str2sl() Reviewed-by: "Serge E. Hallyn" Signed-off-by: Alejandro Colomar --- diff --git a/src/passwd.c b/src/passwd.c index c2468d40d..f1fc6595f 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -21,7 +21,7 @@ #include #include "agetpass.h" -#include "atoi/str2i.h" +#include "atoi/a2i.h" #include "defines.h" #include "getdef.h" #include "memzero.h" @@ -722,7 +722,8 @@ static void update_shadow (void) * appropriate internal format. For finer resolute the chage * command must be used. */ -int main (int argc, char **argv) +int +main(int argc, char **argv) { const struct passwd *pw; /* Password file entry for user */ @@ -800,8 +801,9 @@ int main (int argc, char **argv) usage (E_SUCCESS); /*@notreached@*/break; case 'i': - if ( (str2sl(&inact, optarg) == -1) - || (inact < -1)) { + if (a2sl(&inact, optarg, NULL, 0, -1, LONG_MAX) + == -1) + { fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg); @@ -819,8 +821,9 @@ int main (int argc, char **argv) anyflag = true; break; case 'n': - if ( (str2sl(&age_min, optarg) == -1) - || (age_min < -1)) { + if (a2sl(&age_min, optarg, NULL, 0, -1, LONG_MAX) + == -1) + { fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg); @@ -854,8 +857,9 @@ int main (int argc, char **argv) anyflag = true; break; case 'w': - if ( (str2sl(&warn, optarg) == -1) - || (warn < -1)) { + if (a2sl(&warn, optarg, NULL, 0, -1, LONG_MAX) + == -1) + { (void) fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg); @@ -865,8 +869,9 @@ int main (int argc, char **argv) anyflag = true; break; case 'x': - if ( (str2sl(&age_max, optarg) == -1) - || (age_max < -1)) { + if (a2sl(&age_max, optarg, NULL, 0, -1, LONG_MAX) + == -1) + { (void) fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg);