This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
cygwin.dll/setpwent bug
- To: gnu-win32 at cygnus dot com, noer at cygnus dot com
- Subject: cygwin.dll/setpwent bug
- From: newsham at lava dot net (Tim Newsham)
- Date: Wed, 29 Oct 1997 12:19:18 -1000 (HST)
Hi,
Looks like there is a bug in setpwent/endpwent functions
in winsup/passwd.cc. The following program should dump all
the usernames in /etc/passwd. Instead it dumps only the last
username. This is because setpwent sets the pointer to the last
line in the file, not the first, and getpwent moves forward
in this file. The fix is:
----- start diff ----
*** passwd.cc.orig Wed Oct 29 12:20:35 1997
--- passwd.cc Wed Oct 29 12:20:51 1997
***************
*** 207,220 ****
void
setpwent (void)
{
! i = curr_lines - 1;
}
extern "C"
void
endpwent (void)
{
! i = 0;
}
extern "C"
--- 207,220 ----
void
setpwent (void)
{
! i = 0;
}
extern "C"
void
endpwent (void)
{
! i = curr_lines;
}
extern "C"
----- end diff ----
the test program is:
----- start dumppw.c ----
#include <pwd.h>
int
main()
{
struct passwd *p;
setpwent();
while((p = getpwent())) {
printf("%s %d\n", p->pw_name, p->pw_passwd);
}
printf("done\n");
return 0;
}
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".