]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/get_uid.c: get_uid(): Reimplement in terms of a2i()
authorAlejandro Colomar <alx@kernel.org>
Tue, 9 Jan 2024 16:40:51 +0000 (17:40 +0100)
committerAlejandro Colomar <alx@kernel.org>
Sat, 29 Jun 2024 18:00:18 +0000 (20:00 +0200)
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/get_uid.c

index 77fe9660a87f58d4e3f5e3b8dcc6fc54f14d88bf..1224a9a7b4957b93fb097ff4e1e7dae572f3a00e 100644 (file)
@@ -1,34 +1,18 @@
-/*
- * SPDX-FileCopyrightText: 2009       , Nicolas François
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
+// SPDX-FileCopyrightText: 2009, Nicolas François
+// SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
 
 
 #include <config.h>
 
 #ident "$Id$"
 
+#include "atoi/a2i.h"
 #include "prototypes.h"
-#include "defines.h"
 
 
 int
 get_uid(const char *uidstr, uid_t *uid)
 {
-       char       *end;
-       long long  val;
-
-       errno = 0;
-       val = strtoll(uidstr, &end, 10);
-       if (   ('\0' == *uidstr)
-           || ('\0' != *end)
-           || (0 != errno)
-           || (/*@+longintegral@*/val != (uid_t)val)/*@=longintegral@*/) {
-               return -1;
-       }
-
-       *uid = val;
-       return 0;
+       return a2i(uid_t, uid, uidstr, NULL, 10, type_min(uid_t), type_max(uid_t));
 }
-