summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeoffrey Thomas <geofft@twosigma.com>2021-03-25 17:40:36 -0400
committerGeoffrey Thomas <geofft@ldpreload.com>2021-03-25 17:49:57 -0400
commit2b6f77a25762e2b4afd1c3b446fd0f477f862436 (patch)
tree87a2550eef6a5ab7f5507bf65adffef6e2063783 /src
parent6af11c1e70b02e1af36fdc339238d3a117fd3a94 (diff)
downloadnix-2b6f77a25762e2b4afd1c3b446fd0f477f862436.zip
unistd: Increase maximum passwd/group buffer to 1MB
We have one UNIX group that contains most of our users whose size is about 20 kB, so `Group::from_name` is failing with ERANGE. The discussion on PR #864 suggests that 1 MB is a reasonable maximum - it follows what FreeBSD's libc does. (glibc appears to have no maximum on the _r function and will just double the buffer until malloc fails, but that's not particularly Rusty.)
Diffstat (limited to 'src')
-rw-r--r--src/unistd.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/unistd.rs b/src/unistd.rs
index f93c2192..d3afeac6 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
@@ -2641,10 +2641,10 @@ impl User {
libc::size_t,
*mut *mut libc::passwd) -> libc::c_int
{
- let buflimit = 16384;
+ let buflimit = 1048576;
let bufsize = match sysconf(SysconfVar::GETPW_R_SIZE_MAX) {
Ok(Some(n)) => n as usize,
- Ok(None) | Err(_) => buflimit as usize,
+ Ok(None) | Err(_) => 16384,
};
let mut cbuf = Vec::with_capacity(bufsize);
@@ -2762,10 +2762,10 @@ impl Group {
libc::size_t,
*mut *mut libc::group) -> libc::c_int
{
- let buflimit = 16384;
+ let buflimit = 1048576;
let bufsize = match sysconf(SysconfVar::GETGR_R_SIZE_MAX) {
Ok(Some(n)) => n as usize,
- Ok(None) | Err(_) => buflimit as usize,
+ Ok(None) | Err(_) => 16384,
};
let mut cbuf = Vec::with_capacity(bufsize);