File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -1114,18 +1114,22 @@ impl TryFrom<CK_ATTRIBUTE> for Attribute {
11141114 Ok ( Attribute :: ValidationVersion ( Version :: new ( val[ 0 ] , val[ 1 ] ) ) )
11151115 }
11161116 AttributeType :: AllowedMechanisms => {
1117- let val = unsafe {
1118- std:: slice:: from_raw_parts (
1119- attribute. pValue as * const CK_MECHANISM_TYPE ,
1120- attribute. ulValueLen . try_into ( ) ?,
1121- )
1122- } ;
1123- let types: Vec < MechanismType > = val
1124- . iter ( )
1125- . copied ( )
1126- . map ( |t| t. try_into ( ) )
1127- . collect :: < Result < Vec < MechanismType > > > ( ) ?;
1128- Ok ( Attribute :: AllowedMechanisms ( types) )
1117+ if attribute. ulValueLen == 0 {
1118+ Ok ( Attribute :: AllowedMechanisms ( Vec :: < MechanismType > :: new ( ) ) )
1119+ } else {
1120+ let val = unsafe {
1121+ std:: slice:: from_raw_parts (
1122+ attribute. pValue as * const CK_MECHANISM_TYPE ,
1123+ attribute. ulValueLen . try_into ( ) ?,
1124+ )
1125+ } ;
1126+ let types: Vec < MechanismType > = val
1127+ . iter ( )
1128+ . copied ( )
1129+ . map ( |t| t. try_into ( ) )
1130+ . collect :: < Result < Vec < MechanismType > > > ( ) ?;
1131+ Ok ( Attribute :: AllowedMechanisms ( types) )
1132+ }
11291133 }
11301134 AttributeType :: EndDate => {
11311135 if val. is_empty ( ) {
You can’t perform that action at this time.
0 commit comments