File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 33use 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 } ,
You can’t perform that action at this time.
0 commit comments