Skip to content

Commit d01f442

Browse files
committed
objects: Do not attempt to alloc memory for unavailable attributes
Signed-off-by: Jakub Jelen <[email protected]>
1 parent 383a61d commit d01f442

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cryptoki/src/object.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,8 @@ pub enum AttributeInfo {
13781378
Sensitive,
13791379
/// The attribute is available to get from the object and has the specified size in bytes.
13801380
Available(usize),
1381+
/// The attribute is not available.
1382+
Unavailable,
13811383
}
13821384

13831385
#[derive(Debug, Copy, Clone, PartialEq, Eq)]

cryptoki/src/session/object_management.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,11 @@ impl Session {
454454
))
455455
} {
456456
Rv::Ok => {
457-
results.push(AttributeInfo::Available(template[0].ulValueLen.try_into()?))
457+
if template[0].ulValueLen == CK_UNAVAILABLE_INFORMATION {
458+
results.push(AttributeInfo::Unavailable)
459+
} else {
460+
results.push(AttributeInfo::Available(template[0].ulValueLen.try_into()?))
461+
}
458462
}
459463
Rv::Error(RvError::AttributeSensitive) => results.push(AttributeInfo::Sensitive),
460464
Rv::Error(RvError::AttributeTypeInvalid) => {

0 commit comments

Comments
 (0)