summaryrefslogtreecommitdiffstats
path: root/lib/get_gid.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 16:18:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 16:18:39 +0000
commit5242eef8fc54636a41701fd9d7083ba6e4a4e0b3 (patch)
treee6a0980092957865a937cc0f34446df3d5194e99 /lib/get_gid.c
parentReleasing progress-linux version 1:4.13+dfsg1-5~progress7.99u1. (diff)
downloadshadow-5242eef8fc54636a41701fd9d7083ba6e4a4e0b3.tar.xz
shadow-5242eef8fc54636a41701fd9d7083ba6e4a4e0b3.zip
Merging upstream version 1:4.15.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/get_gid.c')
-rw-r--r--lib/get_gid.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/get_gid.c b/lib/get_gid.c
index cbcd6f4..2420137 100644
--- a/lib/get_gid.c
+++ b/lib/get_gid.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_gid (const char *gidstr, gid_t *gid)
+
+int
+get_gid(const char *gidstr, gid_t *gid)
{
- long long int val;
- char *endptr;
+ char *end;
+ long long val;
errno = 0;
- val = strtoll (gidstr, &endptr, 10);
+ val = strtoll(gidstr, &end, 10);
if ( ('\0' == *gidstr)
- || ('\0' != *endptr)
- || (ERANGE == errno)
+ || ('\0' != *end)
+ || (0 != errno)
|| (/*@+longintegral@*/val != (gid_t)val)/*@=longintegral@*/) {
- return 0;
+ return -1;
}
- *gid = (gid_t)val;
- return 1;
+ *gid = val;
+ return 0;
}