]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/getdef.c: getdef_unum(): Fix wrong limit check
authorAlejandro Colomar <alx@kernel.org>
Tue, 9 Jan 2024 19:00:03 +0000 (20:00 +0100)
committerAlejandro Colomar <alx@kernel.org>
Tue, 2 Jul 2024 20:52:31 +0000 (22:52 +0200)
The limit, since it's an unsigned int, should have been UINT_MAX, not
INT_MAX.  By calling a2ui() we can fix that and simplify too.

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/getdef.c

index 624a056623803e55b91a92a64cbe1dd7a9451e81..5475b40e0d08fddb83a3ff045ff472f9fd770fa2 100644 (file)
@@ -268,10 +268,11 @@ getdef_num(const char *item, int dflt)
  * values are handled.
  */
 
-unsigned int getdef_unum (const char *item, unsigned int dflt)
+unsigned int
+getdef_unum(const char *item, unsigned int dflt)
 {
-       struct itemdef *d;
-       long val;
+       unsigned int    val;
+       struct itemdef  *d;
 
        if (!def_loaded) {
                def_load ();
@@ -282,9 +283,7 @@ unsigned int getdef_unum (const char *item, unsigned int dflt)
                return dflt;
        }
 
-       if (   (str2sl(&val, d->value) == -1)
-           || (val < 0)
-           || (val > INT_MAX)) {
+       if (a2ui(&val, d->value, NULL, 0, 0, UINT_MAX) == -1) {
                fprintf (shadow_logfd,
                         _("configuration error - cannot parse %s value: '%s'"),
                         item, d->value);