Skip to content

Commit 523396a

Browse files
authored
Merge pull request #498 from Superhepper/lint-clippy-1.76
Fixes lints reported by Clippy in rust version 1.76.
2 parents d5f614a + 2ea79a1 commit 523396a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tss-esapi/src/context/general_esys_tr.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::{
44
constants::tss::TPM2_RH_UNASSIGNED,
55
context::handle_manager::HandleDropAction,
6-
ffi::to_owned_bytes,
6+
ffi::{to_owned_bytes, FfiSizeType},
77
handles::ObjectHandle,
88
handles::{handle_conversion::TryIntoNotNone, TpmHandle},
99
structures::Auth,
@@ -516,17 +516,15 @@ impl Context {
516516
/// let new_handle = context.tr_deserialize(&data).unwrap();
517517
/// assert_eq!(public_key, context.read_public(new_handle.into()).unwrap());
518518
/// ```
519-
pub fn tr_deserialize(&mut self, buffer: &Vec<u8>) -> Result<ObjectHandle> {
519+
pub fn tr_deserialize(&mut self, buffer: &[u8]) -> Result<ObjectHandle> {
520520
let mut handle = TPM2_RH_UNASSIGNED;
521+
let size = FfiSizeType::try_from(buffer.len())?;
521522
ReturnCode::ensure_success(
522523
unsafe {
523524
Esys_TR_Deserialize(
524525
self.mut_context(),
525526
buffer.as_ptr(),
526-
buffer.len().try_into().map_err(|e| {
527-
error!("Failed to convert buffer len to usize: {}", e);
528-
Error::local_error(WrapperErrorKind::InvalidParam)
529-
})?,
527+
size.into(),
530528
&mut handle,
531529
)
532530
},

0 commit comments

Comments
 (0)