From 65084197a82714e7a637a6a89f6720aa096d7ff1 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 19 Jun 2022 13:55:22 -0400 Subject: [PATCH] Fix incorrect pointer cast in get_rng When passing in a specific algorithm type to the get_rng function, a pointer to the `Option`-wrapped value was incorrectly being passed in. The pointer should be to the `RngAlgorithmType` inside the `Option` instead. Fixes https://github.com/rust-osdev/uefi-rs/issues/446 --- src/proto/rng.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/proto/rng.rs b/src/proto/rng.rs index bf98ad383..420f9b1ea 100644 --- a/src/proto/rng.rs +++ b/src/proto/rng.rs @@ -122,9 +122,9 @@ impl Rng { pub fn get_rng(&mut self, algorithm: Option, buffer: &mut [u8]) -> Result { let buffer_length = buffer.len(); - let algo = match algorithm { + let algo = match algorithm.as_ref() { None => ptr::null(), - Some(algo) => &algo as *const RngAlgorithmType, + Some(algo) => algo as *const RngAlgorithmType, }; unsafe { (self.get_rng)(self, algo, buffer_length, buffer.as_mut_ptr()).into() }