Skip to content

Commit a2b1713

Browse files
authored
zeroize: fix fallback code used by optimization_barrier (#1551)
The previous fallback code may potentially read uninitialized memory as `u8`.
1 parent 3c5aa70 commit a2b1713

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎zeroize/CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## 1.9.1 (UNRELEASED)
88
### Fixed
99
- False positive failures in proxy allocator test ([#1538])
10+
- Potential uninitialized memory read in fallback code used by `optimization_barrier` ([#1551])
1011

1112
[#1538]: https://github.com/RustCrypto/utils/pull/1538
13+
[#1551]: https://github.com/RustCrypto/utils/pull/1551
1214

1315
## 1.9.0 (2026-06-12)
1416
### Added

‎zeroize/src/barrier.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ pub fn optimization_barrier<T: ?Sized>(val: &T) {
9191
/// `#[inline(never)]` and `read_volatile`.
9292
#[inline(never)]
9393
fn custom_black_box(p: *const u8) {
94-
let _ = unsafe { core::ptr::read_volatile(p) };
94+
use core::mem::MaybeUninit;
95+
96+
let _: MaybeUninit<u8> = unsafe { core::ptr::read_volatile(p.cast()) };
9597
}
9698

9799
core::hint::black_box(val);

0 commit comments

Comments
 (0)