From 8d0cf92fd25c8f81e21cb42dbfe695b4ad4be541 Mon Sep 17 00:00:00 2001 From: Rob Sordi Date: Mon, 22 Sep 2025 17:47:17 -0400 Subject: [PATCH] Cast the 'cap' argument of 'getgrnam_r' to 'i32' on AIX to match the signature in the AIX libc --- changelog/2677.fixed.md | 1 + src/unistd.rs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 changelog/2677.fixed.md diff --git a/changelog/2677.fixed.md b/changelog/2677.fixed.md new file mode 100644 index 0000000000..c3b51896ff --- /dev/null +++ b/changelog/2677.fixed.md @@ -0,0 +1 @@ +Cast the 'cap' argument of 'getgrnam_r' to 'i32' on AIX to match the signature in the AIX libc \ No newline at end of file diff --git a/src/unistd.rs b/src/unistd.rs index 8995fbe02e..c93e4eae50 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -3940,7 +3940,21 @@ impl Group { // at `grp`. unsafe { Group::from_anything(|grp, cbuf, cap, res| { - libc::getgrnam_r(name.as_ptr(), grp, cbuf, cap, res) + let converted_cap = { + // The AIX signature of 'getgrnam_r()' differs from the POSIX + // specification, which expects 'buf_size' to be of type + // 'size_t', whereas AIX uses'int' + #[cfg(target_os = "aix")] + { + cap as i32 + } + #[cfg(not(target_os = "aix"))] + { + cap + } + }; + + libc::getgrnam_r(name.as_ptr(), grp, cbuf, converted_cap, res) }) } }