From 38df5caad3e7f0c2c3aea0db8228baea2978d6ed Mon Sep 17 00:00:00 2001 From: Gary Ching-Pang Lin Date: Tue, 16 Jun 2015 11:41:32 -0400 Subject: [PATCH] MokManager: fix the hash list counting in delete match_hash() requests the number of keys in a list and it was mistakenly replaced with the size of the Mok node. This would made MokManager to remove the whole Mok node instead of one hash. Signed-off-by: Gary Ching-Pang Lin --- MokManager.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MokManager.c b/MokManager.c index 12a91e9..2972d09 100644 --- a/MokManager.c +++ b/MokManager.c @@ -1080,6 +1080,7 @@ static void delete_hash_in_list (UINT8 *hash, UINT32 hash_size, { EFI_GUID HashType = EFI_CERT_SHA256_GUID; UINT32 sig_size; + UINT32 list_num; int i, del_ind; void *start, *end; UINT32 remain; @@ -1091,8 +1092,10 @@ static void delete_hash_in_list (UINT8 *hash, UINT32 hash_size, (mok[i].MokSize < sig_size)) continue; + list_num = mok[i].MokSize / sig_size; + del_ind = match_hash(hash, hash_size, 0, mok[i].Mok, - mok[i].MokSize); + list_num); while (del_ind >= 0) { /* Remove the hash */ if (sig_size == mok[i].MokSize) { @@ -1107,9 +1110,10 @@ static void delete_hash_in_list (UINT8 *hash, UINT32 hash_size, mem_move(start, end, remain); mok[i].MokSize -= sig_size; + list_num--; del_ind = match_hash(hash, hash_size, del_ind, - mok[i].Mok, mok[i].MokSize); + mok[i].Mok, list_num); } } }