about summary refs log tree commit diff
path: root/src/passwd/getgrent_a.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-07-19 01:34:28 -0400
committerRich Felker <dalias@aerifal.cx>2013-07-19 01:34:28 -0400
commit648c3b4e18b2ce2b6af7d44783e42ca267ea49f5 (patch)
tree1b57c9dfd2196639b331fb38c10aecf057dc733c /src/passwd/getgrent_a.c
parentdf065781ee913681ba86a636a2516cb0162cab19 (diff)
downloadmusl-648c3b4e18b2ce2b6af7d44783e42ca267ea49f5.tar.gz
musl-648c3b4e18b2ce2b6af7d44783e42ca267ea49f5.tar.xz
musl-648c3b4e18b2ce2b6af7d44783e42ca267ea49f5.zip
change uid_t, gid_t, and id_t to unsigned types
this change is both to fix one of the remaining type (and thus C++
ABI) mismatches with glibc/LSB and to allow use of the full range of
uid and gid values, if so desired.

passwd/group access functions were not prepared to deal with unsigned
values, so they too have been fixed with this commit.
Diffstat (limited to 'src/passwd/getgrent_a.c')
-rw-r--r--src/passwd/getgrent_a.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/passwd/getgrent_a.c b/src/passwd/getgrent_a.c
index 780560dd..2cb85215 100644
--- a/src/passwd/getgrent_a.c
+++ b/src/passwd/getgrent_a.c
@@ -1,6 +1,13 @@
 #include "pwf.h"
 #include <pthread.h>
 
+static unsigned atou(char **s)
+{
+	unsigned x;
+	for (x=0; **s-'0'<10U; ++*s) x=10*x+(**s-'0');
+	return x;
+}
+
 struct group *__getgrent_a(FILE *f, struct group *gr, char **line, size_t *size, char ***mem, size_t *nmem)
 {
 	ssize_t l;
@@ -24,8 +31,8 @@ struct group *__getgrent_a(FILE *f, struct group *gr, char **line, size_t *size,
 		*s++ = 0; gr->gr_passwd = s;
 		if (!(s = strchr(s, ':'))) continue;
 
-		*s++ = 0; gr->gr_gid = atoi(s);
-		if (!(s = strchr(s, ':'))) continue;
+		*s++ = 0; gr->gr_gid = atou(&s);
+		if (*s != ':') continue;
 
 		*s++ = 0; mems = s;
 		break;