glibc-bug in fgetgrent
Hello developer(s),
There is a bug in glibc2 (package libc6-dev.2.1.1-6). At our school we
have a *huge* group named pupils (ca. 600 members). A simple test program
using getgrent works perfectly:
#include <stdio.h>
#include <stdlib.h>
#include <grp.h>
#include <sys/types.h>
int main(void)
{
struct group * g;
setgrent();
while(1)
{
g = getgrent();
if(!g)
break;
printf("%s: %d\n",g->gr_name,g->gr_gid);
}
}
If you do the same using fgetgrent the huge group is skipped and at the
end of file fgetgrent is eating all available memory. Not so good :-(
Here is the second test program:
#include <stdio.h>
#include <stdlib.h>
#include <grp.h>
#include <sys/types.h>
int main(void)
{
struct group * g;
FILE * f;
f = fopen("/etc/group","r");
while(1)
{
g = fgetgrent(f);
if(!g)
break;
printf("%s: %d\n",g->gr_name,g->gr_gid);
}
}
I hope for help ... Michael Karcher
Reply to: