diff options
| author | Alexis Beingessner <a.beingessner@gmail.com> | 2022-03-22 21:29:38 -0400 |
|---|---|---|
| committer | Aria Beingessner <a.beingessner@gmail.com> | 2022-03-29 20:18:27 -0400 |
| commit | 09395f626b2ff7378fb250300654b1817953a390 (patch) | |
| tree | 92ff9d059a640e5638062b633f1e62a2665701a9 /library/std/src/sys/unix/memchr.rs | |
| parent | 68643603ad00900d6a91a0dae90bb2ebb4f0db48 (diff) | |
| download | rust-09395f626b2ff7378fb250300654b1817953a390.tar.gz rust-09395f626b2ff7378fb250300654b1817953a390.zip | |
Make some linux/unix APIs better conform to strict provenance.
This largely makes the stdlib conform to strict provenance on Ubuntu. Some hairier things have been left alone for now.
Diffstat (limited to 'library/std/src/sys/unix/memchr.rs')
| -rw-r--r-- | library/std/src/sys/unix/memchr.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/memchr.rs b/library/std/src/sys/unix/memchr.rs index a9273ea676c..a3e4f8ff56a 100644 --- a/library/std/src/sys/unix/memchr.rs +++ b/library/std/src/sys/unix/memchr.rs @@ -9,7 +9,7 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> { haystack.len(), ) }; - if p.is_null() { None } else { Some(p as usize - (haystack.as_ptr() as usize)) } + if p.is_null() { None } else { Some(p.addr() - haystack.as_ptr().addr()) } } pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> { @@ -26,7 +26,7 @@ pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> { haystack.len(), ) }; - if p.is_null() { None } else { Some(p as usize - (haystack.as_ptr() as usize)) } + if p.is_null() { None } else { Some(p.addr() - haystack.as_ptr().addr()) } } #[cfg(not(target_os = "linux"))] |
