Skip to content

Commit 04bdd29

Browse files
Rob SordiRob Sordi
authored andcommitted
Cast the 'cap' argument of 'getgrnam_r' to 'i32' on AIX to match the signature in the AIX libc
1 parent e1e630f commit 04bdd29

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

changelog/2677.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cast the 'cap' argument of 'getgrnam_r' to 'i32' on AIX to match the signature in the AIX libc

changelog/XXXX.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cast the 'cap' argument of 'getgrnam_r' to 'i32' on AIX to match the signature in the AIX libc

src/unistd.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3940,7 +3940,21 @@ impl Group {
39403940
// at `grp`.
39413941
unsafe {
39423942
Group::from_anything(|grp, cbuf, cap, res| {
3943-
libc::getgrnam_r(name.as_ptr(), grp, cbuf, cap, res)
3943+
let converted_cap = {
3944+
// The AIX signature of 'getgrnam_r()' differs from the POSIX
3945+
// specification, which expects 'buf_size' to be of type
3946+
// 'size_t', whereas AIX uses'int'
3947+
#[cfg(target_os = "aix")]
3948+
{
3949+
cap as i32
3950+
}
3951+
#[cfg(not(target_os = "aix"))]
3952+
{
3953+
cap
3954+
}
3955+
};
3956+
3957+
libc::getgrnam_r(name.as_ptr(), grp, cbuf, converted_cap, res)
39443958
})
39453959
}
39463960
}

0 commit comments

Comments
 (0)