ruby-changes:27301
From: kosaki <ko1@a...>
Date: Thu, 21 Feb 2013 13:52:52 +0900 (JST)
Subject: [ruby-changes:27301] kosaki:r39353 (trunk): * file.c (rb_group_member): added an error check. SUS says,
kosaki 2013-02-21 13:52:38 +0900 (Thu, 21 Feb 2013) New Revision: 39353 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39353 Log: * file.c (rb_group_member): added an error check. SUS says, getgroups(small_value) may return EINVAL. Modified files: trunk/ChangeLog trunk/file.c Index: ChangeLog =================================================================== --- ChangeLog (revision 39352) +++ ChangeLog (revision 39353) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Feb 21 13:47:59 2013 KOSAKI Motohiro <kosaki.motohiro@g...> + + * 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@g...> * file.c (RB_MAX_GROUPS): moved to Index: file.c =================================================================== --- file.c (revision 39352) +++ file.c (revision 39353) @@ -1036,7 +1036,7 @@ rb_group_member(GETGROUPS_T gid) https://github.com/ruby/ruby/blob/trunk/file.c#L1036 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) https://github.com/ruby/ruby/blob/trunk/file.c#L1044 v = 0; } } + if (anum == -1) + return FALSE; while (--anum >= 0) { if (gary[anum] == gid) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/