#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;
char *s, *mems;
size_t i;
-
+ int cs;
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
for (;;) {
if ((l=getline(line, size, f)) < 0) {
free(*line);
*line = 0;
- return 0;
+ gr = 0;
+ goto end;
}
line[0][l-1] = 0;
*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;
mem[0][0] = 0;
}
gr->gr_mem = *mem;
+end:
+ pthread_setcancelstate(cs, 0);
return gr;
}