From c4f781e6e3c4ae13b4dce386b32b75e7e17fc692 Mon Sep 17 00:00:00 2001 From: shimun Date: Fri, 27 Mar 2020 19:56:57 +0100 Subject: [PATCH] only process keyslots within a given range --- src/luks.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/luks.rs b/src/luks.rs index cda0ff4..a052077 100644 --- a/src/luks.rs +++ b/src/luks.rs @@ -46,10 +46,10 @@ pub fn add_key>( pub fn remove_keyslots>(path: P, exclude: &[u32]) -> Fido2LuksResult { let mut device = load_device_handle(path)?; - let mut slot = 0; let mut handle; let mut destroyed = 0; - loop { + //TODO: detect how many keyslots there are instead of trying within a given range + for slot in 0..1024 { handle = device.keyslot_handle(Some(slot)); match handle.status()? { KeyslotInfo::Inactive => continue, @@ -63,7 +63,6 @@ pub fn remove_keyslots>(path: P, exclude: &[u32]) -> Fido2LuksRes KeyslotInfo::ActiveLast => break, _ => (), } - slot += 1; } Ok(destroyed) }