|
From: <sv...@va...> - 2014-07-31 12:13:33
|
Author: florian
Date: Thu Jul 31 12:13:26 2014
New Revision: 14216
Log:
Get all available groups. Simply resize the groups buffer until large
enough. Free it later.
Modified:
branches/BUF_REMOVAL/coregrind/m_libcfile.c
Modified: branches/BUF_REMOVAL/coregrind/m_libcfile.c
==============================================================================
--- branches/BUF_REMOVAL/coregrind/m_libcfile.c (original)
+++ branches/BUF_REMOVAL/coregrind/m_libcfile.c Thu Jul 31 12:13:26 2014
@@ -662,8 +662,15 @@
if (VG_(getegid)() == st.gid)
grpmatch = 1;
else {
- UInt groups[32];
- Int ngrp = VG_(getgroups)(32, groups);
+ UInt *groups = NULL;
+ Int ngrp, groups_size = 0;
+ do {
+ groups_size += 32;
+ groups = VG_(arena_realloc)(VG_AR_CORE, "check_executable",
+ groups, groups_size);
+ ngrp = VG_(getgroups)(groups_size, groups);
+ if (ngrp == -1) break; // failed
+ } while (ngrp == groups_size);
Int i;
/* ngrp will be -1 if VG_(getgroups) failed. */
for (i = 0; i < ngrp; i++) {
@@ -672,6 +679,7 @@
break;
}
}
+ if (groups) VG_(free)(groups);
}
if (grpmatch) {
|