Skip to content

Commit ebc6c0d

Browse files
authored
Change ptr::eq to ptr::addr_eq where semantically more correct (#3105)
* Change ptr::eq to ptr::addr_eq where semantically more correct * not needed here?
1 parent c863c8b commit ebc6c0d

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

libafl_bolts/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ mod windows_logging {
11061106
// Get the handle to standard output
11071107
let h_stdout: HANDLE = get_stdout_handle();
11081108

1109-
if ptr::eq(h_stdout, INVALID_HANDLE_VALUE) {
1109+
if ptr::addr_eq(h_stdout, INVALID_HANDLE_VALUE) {
11101110
eprintln!("Failed to get standard output handle");
11111111
return;
11121112
}

libafl_bolts/src/llmp.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,10 @@ where
15871587
unsafe {
15881588
// log::info!("Sending msg {:?}", msg);
15891589

1590-
assert!(!ptr::eq(self.last_msg_sent, msg), "Message sent twice!");
1590+
assert!(
1591+
!ptr::addr_eq(self.last_msg_sent, msg),
1592+
"Message sent twice!"
1593+
);
15911594
assert!(
15921595
(*msg).tag != LLMP_TAG_UNSET,
15931596
"No tag set on message with id {:?}",

libafl_bolts/src/shmem.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ pub mod unix_shmem {
771771
shm_fd,
772772
0,
773773
);
774-
if ptr::eq(map, libc::MAP_FAILED) {
774+
if ptr::addr_eq(map, libc::MAP_FAILED) {
775775
close(shm_fd);
776776
shm_unlink(filename_path.as_ptr() as *const _);
777777
return Err(Error::last_os_error(format!(
@@ -845,7 +845,7 @@ pub mod unix_shmem {
845845
shm_fd,
846846
0,
847847
);
848-
if ptr::eq(map, libc::MAP_FAILED) {
848+
if ptr::addr_eq(map, libc::MAP_FAILED) {
849849
close(shm_fd);
850850
return Err(Error::last_os_error(format!(
851851
"mmap() failed for map with fd {shm_fd:?}"
@@ -1081,7 +1081,7 @@ pub mod unix_shmem {
10811081
let id_int: i32 = id.into();
10821082
let map = shmat(id_int, ptr::null(), 0) as *mut c_uchar;
10831083

1084-
if ptr::eq(map, ptr::null_mut::<c_uchar>().wrapping_sub(1)) {
1084+
if ptr::addr_eq(map, ptr::null_mut::<c_uchar>().wrapping_sub(1)) {
10851085
return Err(Error::last_os_error(format!(
10861086
"Failed to map the shared mapping with id {id_int}"
10871087
)));
@@ -1250,7 +1250,7 @@ pub mod unix_shmem {
12501250
fd,
12511251
0,
12521252
);
1253-
if ptr::eq(map, usize::MAX as *mut c_void) {
1253+
if ptr::addr_eq(map, usize::MAX as *mut c_void) {
12541254
close(fd);
12551255
return Err(Error::unknown(
12561256
"Failed to map the ashmem mapping".to_string(),
@@ -1285,7 +1285,7 @@ pub mod unix_shmem {
12851285
fd,
12861286
0,
12871287
);
1288-
if ptr::eq(map, usize::MAX as *mut c_void) {
1288+
if ptr::addr_eq(map, usize::MAX as *mut c_void) {
12891289
close(fd);
12901290
return Err(Error::unknown(
12911291
"Failed to map the ashmem mapping".to_string(),
@@ -1434,7 +1434,7 @@ pub mod unix_shmem {
14341434
fd,
14351435
0,
14361436
);
1437-
if ptr::eq(map, libc::MAP_FAILED) {
1437+
if ptr::addr_eq(map, libc::MAP_FAILED) {
14381438
close(fd);
14391439
return Err(Error::unknown(
14401440
"Failed to map the memfd mapping".to_string(),
@@ -1471,7 +1471,7 @@ pub mod unix_shmem {
14711471
fd,
14721472
0,
14731473
);
1474-
if ptr::eq(map, libc::MAP_FAILED) {
1474+
if ptr::addr_eq(map, libc::MAP_FAILED) {
14751475
return Err(Error::last_os_error(format!(
14761476
"mmap() failed for map with fd {fd:?}"
14771477
)));

libafl_frida/src/asan/hook_funcs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ impl AsanRuntime {
16081608
) -> *mut c_void {
16091609
log::trace!("hook_mmap");
16101610
let res = original(addr, length, prot, flags, fd, offset);
1611-
if !ptr::eq(res, -1_isize as *mut c_void) {
1611+
if !ptr::addr_eq(res, ptr::null_mut::<c_void>().wrapping_sub(1)) {
16121612
self.allocator_mut()
16131613
.map_shadow_for_region(res as usize, res as usize + length, true);
16141614
}

0 commit comments

Comments
 (0)