Skip to content

Commit

Permalink
Merge pull request #1792 from kemkemG0/main
Browse files Browse the repository at this point in the history
Modify pointer type from i8 to c_char
  • Loading branch information
Furisto authored Apr 11, 2023
2 parents 32386b2 + 0864622 commit 307e941
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions crates/libcgroups/src/v2/devices/bpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ pub mod prog {
let insns = insns as *const _ as *const bpf_insn;
let opts = libbpf_sys::bpf_prog_load_opts {
kern_version: 0,
log_buf: ptr::null_mut::<i8>(),
log_buf: ptr::null_mut::<::std::os::raw::c_char>(),
log_size: 0,
..Default::default()
};
#[allow(unused_unsafe)]
let prog_fd = unsafe {
bpf_prog_load(
BPF_PROG_TYPE_CGROUP_DEVICE,
ptr::null::<i8>(),
license as *const _ as *const i8,
ptr::null::<::std::os::raw::c_char>(),
license as *const _ as *const ::std::os::raw::c_char,
insns,
insns_cnt as u64,
&opts,
Expand Down
2 changes: 1 addition & 1 deletion crates/libcgroups/src/v2/devices/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod libc {
pub mod libbpf_sys {
pub fn bpf_prog_load(
_type_: libbpf_sys::bpf_prog_type,
_name: *const i8,
_name: *const ::std::os::raw::c_char,
_license: *const ::std::os::raw::c_char,
_insns: *const libbpf_sys::bpf_insn,
_insns_cnt: libbpf_sys::size_t,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,12 @@ fn check_recursive_rsuid() -> TestResult {
File::create(original_file_path.clone())?;
// chmod +s /tmp/rsuid_dir/file && chmod +g /tmp/rsuid_dir/file
let mode = libc::S_ISUID | libc::S_ISGID;
let result = unsafe { libc::chmod(original_file_path.as_ptr() as *const i8, mode) };
let result = unsafe {
libc::chmod(
original_file_path.as_ptr() as *const ::std::os::raw::c_char,
mode,
)
};
if result == -1 {
return Err(anyhow!(std::io::Error::last_os_error()));
}
Expand Down Expand Up @@ -553,7 +558,12 @@ fn check_recursive_rnosymfollow() -> TestResult {
let link_file_path = format!("{}/{}", rnosymfollow_dir_path.to_str().unwrap(), "link");
println!("original file: {original_file_path:?},link file: {link_file_path:?}");
let mode = libc::S_ISUID | libc::S_ISGID;
let result = unsafe { libc::chmod(original_file_path.as_ptr() as *const i8, mode) };
let result = unsafe {
libc::chmod(
original_file_path.as_ptr() as *const ::std::os::raw::c_char,
mode,
)
};
if result == -1 {
return Err(anyhow!(std::io::Error::last_os_error()));
};
Expand Down

0 comments on commit 307e941

Please sign in to comment.