Skip to content

Commit 197f55b

Browse files
authored
refactor: update nix (#2311)
1 parent f34d00d commit 197f55b

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,32 @@ jobs:
4444
- name: before_cache_script
4545
run: rm -rf $CARGO_HOME/registry/index
4646

47+
macos-aarch64:
48+
runs-on: macos-14
49+
env:
50+
TARGET: aarch64-apple-darwin
51+
steps:
52+
- name: checkout
53+
uses: actions/checkout@v4
54+
55+
- name: setup Rust
56+
uses: dtolnay/rust-toolchain@master
57+
with:
58+
toolchain: '${{ env.MSRV }}'
59+
components: clippy
60+
61+
- name: build
62+
uses: ./.github/actions/build
63+
with:
64+
TARGET: "${{ env.TARGET }}"
65+
66+
- name: test
67+
uses: ./.github/actions/test
68+
with:
69+
TARGET: "${{ env.TARGET }}"
70+
71+
- name: before_cache_script
72+
run: rm -rf $CARGO_HOME/registry/index
4773

4874
# Use cross for QEMU-based testing
4975
# cross needs to execute Docker, GitHub Action already has it installed

changelog/2311.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed `::unistd::Group::members` using read_unaligned to avoid crash on misaligned pointers

src/unistd.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,18 +3476,17 @@ impl Group {
34763476
let mut ret = Vec::new();
34773477

34783478
for i in 0.. {
3479-
let u = unsafe { mem.offset(i) };
3480-
if unsafe { (*u).is_null() } {
3479+
let u = unsafe { mem.offset(i).read_unaligned() };
3480+
if u.is_null() {
34813481
break;
34823482
} else {
3483-
let s = unsafe {CStr::from_ptr(*u).to_string_lossy().into_owned()};
3483+
let s = unsafe {CStr::from_ptr(u).to_string_lossy().into_owned()};
34843484
ret.push(s);
34853485
}
34863486
}
34873487

34883488
ret
34893489
}
3490-
34913490
/// # Safety
34923491
///
34933492
/// If `f` writes to its `*mut *mut libc::group` parameter, then it must

test/test_unistd.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,3 +1372,14 @@ fn test_eaccess_file_exists() {
13721372
eaccess(&path, AccessFlags::R_OK | AccessFlags::W_OK)
13731373
.expect("assertion failed");
13741374
}
1375+
1376+
#[test]
1377+
#[cfg(bsd)]
1378+
fn test_group_from() {
1379+
let group = Group::from_name("wheel").unwrap().unwrap();
1380+
assert!(group.name == "wheel");
1381+
let group_id = group.gid;
1382+
let group = Group::from_gid(group_id).unwrap().unwrap();
1383+
assert_eq!(group.gid, group_id);
1384+
assert_eq!(group.name, "wheel");
1385+
}

0 commit comments

Comments
 (0)