diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 16:18:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 16:18:36 +0000 |
commit | 6c3ea4f47ea280811a7fe53a22f7832e4533c9ec (patch) | |
tree | 3d7ed5da23b5dbf6f9e450dfb61642832249c31e /lib/get_uid.c | |
parent | Adding upstream version 1:4.13+dfsg1. (diff) | |
download | shadow-upstream/1%4.15.2.tar.xz shadow-upstream/1%4.15.2.zip |
Adding upstream version 1:4.15.2.upstream/1%4.15.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | lib/get_uid.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/get_uid.c b/lib/get_uid.c index 50f9922..77fe966 100644 --- a/lib/get_uid.c +++ b/lib/get_uid.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ + #include <config.h> #ident "$Id$" @@ -11,21 +12,23 @@ #include "prototypes.h" #include "defines.h" -int get_uid (const char *uidstr, uid_t *uid) + +int +get_uid(const char *uidstr, uid_t *uid) { - long long int val; - char *endptr; + char *end; + long long val; errno = 0; - val = strtoll (uidstr, &endptr, 10); + val = strtoll(uidstr, &end, 10); if ( ('\0' == *uidstr) - || ('\0' != *endptr) - || (ERANGE == errno) + || ('\0' != *end) + || (0 != errno) || (/*@+longintegral@*/val != (uid_t)val)/*@=longintegral@*/) { - return 0; + return -1; } - *uid = (uid_t)val; - return 1; + *uid = val; + return 0; } |