mirror of
https://github.com/bitwarden/browser
synced 2026-02-24 16:43:27 +00:00
Reduce unsafe scope
This commit is contained in:
@@ -39,10 +39,10 @@ pub(super) fn get_operation_signing_public_key(
|
|||||||
clsid: &GUID,
|
clsid: &GUID,
|
||||||
) -> Result<SigningKey, WinWebAuthnError> {
|
) -> Result<SigningKey, WinWebAuthnError> {
|
||||||
let mut len = 0;
|
let mut len = 0;
|
||||||
let mut data = MaybeUninit::uninit();
|
let mut uninit = MaybeUninit::uninit();
|
||||||
unsafe {
|
let data = unsafe {
|
||||||
// SAFETY: We check the OS error code before using the written pointer.
|
// SAFETY: We check the OS error code before using the written pointer.
|
||||||
webauthn_plugin_get_operation_signing_public_key(clsid, &mut len, data.as_mut_ptr())?
|
webauthn_plugin_get_operation_signing_public_key(clsid, &mut len, uninit.as_mut_ptr())?
|
||||||
.ok()
|
.ok()
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
WinWebAuthnError::with_cause(
|
WinWebAuthnError::with_cause(
|
||||||
@@ -51,16 +51,18 @@ pub(super) fn get_operation_signing_public_key(
|
|||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
match NonNull::new(data.assume_init()) {
|
uninit.assume_init()
|
||||||
Some(data) => Ok(SigningKey {
|
};
|
||||||
cbPublicKey: len,
|
|
||||||
pbPublicKey: data,
|
match NonNull::new(data) {
|
||||||
}),
|
Some(data) => Ok(SigningKey {
|
||||||
None => Err(WinWebAuthnError::new(
|
cbPublicKey: len,
|
||||||
ErrorKind::WindowsInternal,
|
pbPublicKey: data,
|
||||||
"Windows returned null pointer when requesting operation signing public key",
|
}),
|
||||||
)),
|
None => Err(WinWebAuthnError::new(
|
||||||
}
|
ErrorKind::WindowsInternal,
|
||||||
|
"Windows returned null pointer when requesting operation signing public key",
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user