Skip to content

Commit

Permalink
fix: unaligned read panic on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
anonkey committed Feb 7, 2024
1 parent 64e2de0 commit 607b0f3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/2311.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed `::unistd::Group::members` crash on misaligned read by read_unaligned use
24 changes: 24 additions & 0 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3569,6 +3569,30 @@ impl Group {
///
/// # Examples
///
// Disable this test on all OS except BSD as wheel group may not exist.
#[cfg_attr(not(bsd), doc = " ```no_run")]
#[cfg_attr(bsd, doc = " ```")]
/// use nix::unistd::Group;
/// // Returns an Result<Option<Group>>, thus the double unwrap.
/// let group = Group::from_name("wheel").unwrap().unwrap();
/// assert!(group.name == "wheel");
/// let group_id = group.gid;
/// let group = Group::from_gid(group_id).unwrap().unwrap();
/// assert_eq!(group.gid, group_id);
/// assert_eq!(group.name, "wheel");
/// ```
// Disable this test on all OS except Apple as everyone group may not exist.
#[cfg_attr(not(apple_targets), doc = " ```no_run")]
#[cfg_attr(apple_targets, doc = " ```")]
/// use nix::unistd::Group;
/// // Returns an Result<Option<Group>>, thus the double unwrap.
/// let group = Group::from_name("everyone").unwrap().unwrap();
/// assert!(group.name == "everyone");
/// let group_id = group.gid;
/// let group = Group::from_gid(group_id).unwrap().unwrap();
/// assert_eq!(group.gid, group_id);
/// assert_eq!(group.name, "everyone");
/// ```
// Disable this test on all OS except Linux as root group may not exist.
#[cfg_attr(not(target_os = "linux"), doc = " ```no_run")]
#[cfg_attr(target_os = "linux", doc = " ```")]
Expand Down

0 comments on commit 607b0f3

Please sign in to comment.