Merge pull request #609 from tlevi/getgrgid_r

Group permission checks sometimes fail with large number of groups
This commit is contained in:
Takeshi Nakatani 2017-05-27 11:02:18 +09:00 committed by GitHub
commit f48826dfe9

View File

@ -510,8 +510,17 @@ int is_uid_include_group(uid_t uid, gid_t gid)
return -ENOMEM;
}
// get group information
if(0 != (result = getgrgid_r(gid, &ginfo, pbuf, maxlen, &pginfo))){
S3FS_PRN_ERR("could not get group information.");
while(ERANGE == (result = getgrgid_r(gid, &ginfo, pbuf, maxlen, &pginfo))){
free(pbuf);
maxlen *= 2;
if(NULL == (pbuf = (char*)malloc(sizeof(char) * maxlen))){
S3FS_PRN_CRIT("failed to allocate memory.");
return -ENOMEM;
}
}
if(0 != result){
S3FS_PRN_ERR("could not get group information(%d).", result);
free(pbuf);
return -result;
}