1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* file.c (rb_group_member): added an error check. SUS says,

getgroups(small_value) may return EINVAL.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kosaki 2013-02-21 04:52:38 +00:00
parent e93a68abfa
commit 8a9dc061f5
2 changed files with 8 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Thu Feb 21 13:47:59 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* file.c (rb_group_member): added an error check. SUS says,
getgroups(small_value) may return EINVAL.
Thu Feb 21 13:37:07 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* file.c (RB_MAX_GROUPS): moved to

4
file.c
View file

@ -1036,7 +1036,7 @@ rb_group_member(GETGROUPS_T gid)
while (groups <= RB_MAX_GROUPS) {
gary = ALLOCV_N(GETGROUPS_T, v, groups);
anum = getgroups(groups, gary);
if (anum != groups)
if (anum != -1 && anum != groups)
break;
groups *= 2;
if (v) {
@ -1044,6 +1044,8 @@ rb_group_member(GETGROUPS_T gid)
v = 0;
}
}
if (anum == -1)
return FALSE;
while (--anum >= 0) {
if (gary[anum] == gid) {