]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
authorAlejandro Colomar <alx@kernel.org>
Tue, 9 Jan 2024 20:21:00 +0000 (21:21 +0100)
committerAlejandro Colomar <alx@kernel.org>
Tue, 2 Jul 2024 20:52:31 +0000 (22:52 +0200)
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/passwd.c

index c2468d40d1d3fd5d06c1b62d343c858e1bad7419..f1fc6595fd195148a77d4ddbf527d54d499dbf88 100644 (file)
@@ -21,7 +21,7 @@
 #include <time.h>
 
 #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);