Skip to content

Commit

Permalink
Correct checking loop in group_member.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed Jun 19, 2010
1 parent 63c4ed2 commit ac2b484
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2010-06-19 Ulrich Drepper <drepper@redhat.com>

[BZ #11701]
* posix/group_member.c (__group_member): Correct checking loop.

* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Handle
OOM in getpwuid_r correctly. Return error number when the caller
should return, otherwise -1.
Expand Down
8 changes: 6 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GNU C Library NEWS -- history of user-visible changes. 2010-5-19
GNU C Library NEWS -- history of user-visible changes. 2010-6-19
Copyright (C) 1992-2009, 2010 Free Software Foundation, Inc.
See the end for copying conditions.

Expand All @@ -7,7 +7,11 @@ using `glibc' in the "product" field.

Version 2.13

* POWER7 optimizations: memset
* The following bugs are resolved with this release:

11640, 11701

* POWER7 optimizations: memset, memcmp, strncmp

Version 2.12

Expand Down
9 changes: 5 additions & 4 deletions posix/group_member.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* `group_member' -- test if process is in a given group.
Copyright (C) 1995, 1997, 2002 Free Software Foundation, Inc.
Copyright (C) 1995, 1997, 2002, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -39,10 +39,11 @@ __group_member (gid)
groups = __alloca (size * sizeof *groups);
n = __getgroups (size, groups);
size *= 2;
} while (n == size / 2);
}
while (n == size / 2);

while (n >= 0)
if (groups[n--] == gid)
while (n-- > 0)
if (groups[n] == gid)
return 1;

return 0;
Expand Down

0 comments on commit ac2b484

Please sign in to comment.