Skip to content

Commit c5d75b8

Browse files
bors[bot]geofft
andauthored
Merge #1409
1409: unistd: Increase maximum passwd/group buffer to 1MB r=asomers a=geofft 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.) Co-authored-by: Geoffrey Thomas <[email protected]>
2 parents 6af11c1 + 2b6f77a commit c5d75b8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/unistd.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,10 +2641,10 @@ impl User {
26412641
libc::size_t,
26422642
*mut *mut libc::passwd) -> libc::c_int
26432643
{
2644-
let buflimit = 16384;
2644+
let buflimit = 1048576;
26452645
let bufsize = match sysconf(SysconfVar::GETPW_R_SIZE_MAX) {
26462646
Ok(Some(n)) => n as usize,
2647-
Ok(None) | Err(_) => buflimit as usize,
2647+
Ok(None) | Err(_) => 16384,
26482648
};
26492649

26502650
let mut cbuf = Vec::with_capacity(bufsize);
@@ -2762,10 +2762,10 @@ impl Group {
27622762
libc::size_t,
27632763
*mut *mut libc::group) -> libc::c_int
27642764
{
2765-
let buflimit = 16384;
2765+
let buflimit = 1048576;
27662766
let bufsize = match sysconf(SysconfVar::GETGR_R_SIZE_MAX) {
27672767
Ok(Some(n)) => n as usize,
2768-
Ok(None) | Err(_) => buflimit as usize,
2768+
Ok(None) | Err(_) => 16384,
27692769
};
27702770

27712771
let mut cbuf = Vec::with_capacity(bufsize);

0 commit comments

Comments
 (0)