summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Ching-Pang Lin <glin@suse.com>2014-06-25 10:58:23 -0400
committerPeter Jones <pjones@redhat.com>2014-06-25 10:58:23 -0400
commit875eb1b9d501d853b2c44f86a32a51b59f85eef9 (patch)
tree4915bd253231fb612a65ada3a41010278f278d8a
parent9ea3d9b401ed73ae95b60e6b566f9293af3ac4d7 (diff)
downloadefi-boot-shim-875eb1b9d501d853b2c44f86a32a51b59f85eef9.tar.gz
efi-boot-shim-875eb1b9d501d853b2c44f86a32a51b59f85eef9.zip
Simplify the checking of SB and DB states
MokSBState and MokDBState are just 1 byte variables, so a UINT8 local variable is sufficient to include the content. Signed-off-by: Gary Ching-Pang Lin <glin@suse.com> Conflicts: shim.c
-rw-r--r--shim.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/shim.c b/shim.c
index fe73ec1a..ea8eba81 100644
--- a/shim.c
+++ b/shim.c
@@ -1609,16 +1609,15 @@ static EFI_STATUS check_mok_sb (void)
{
EFI_GUID shim_lock_guid = SHIM_LOCK_GUID;
EFI_STATUS status = EFI_SUCCESS;
- UINT8 *MokSBState = NULL;
- UINTN MokSBStateSize = 0;
+ UINT8 MokSBState;
+ UINTN MokSBStateSize = sizeof(MokSBState);
UINT32 attributes;
user_insecure_mode = 0;
ignore_db = 0;
- status = get_variable_attr(L"MokSBState", &MokSBState, &MokSBStateSize,
- shim_lock_guid, &attributes);
-
+ status = uefi_call_wrapper(RT->GetVariable, 5, L"MokSBState", &shim_lock_guid,
+ &attributes, &MokSBStateSize, &MokSBState);
if (status != EFI_SUCCESS)
return EFI_ACCESS_DENIED;
@@ -1633,13 +1632,11 @@ static EFI_STATUS check_mok_sb (void)
}
status = EFI_ACCESS_DENIED;
} else {
- if (*(UINT8 *)MokSBState == 1) {
+ if (MokSBState == 1) {
user_insecure_mode = 1;
}
}
- FreePool(MokSBState);
-
return status;
}
@@ -1651,13 +1648,12 @@ static EFI_STATUS check_mok_db (void)
{
EFI_GUID shim_lock_guid = SHIM_LOCK_GUID;
EFI_STATUS status = EFI_SUCCESS;
- UINT8 *MokDBState = NULL;
- UINTN MokDBStateSize = 0;
+ UINT8 MokDBState;
+ UINTN MokDBStateSize = sizeof(MokDBStateSize);
UINT32 attributes;
- status = get_variable_attr(L"MokDBState", &MokDBState, &MokDBStateSize,
- shim_lock_guid, &attributes);
-
+ status = uefi_call_wrapper(RT->GetVariable, 5, L"MokDBState", &shim_lock_guid,
+ &attributes, &MokDBStateSize, &MokDBState);
if (status != EFI_SUCCESS)
return EFI_ACCESS_DENIED;
@@ -1674,13 +1670,11 @@ static EFI_STATUS check_mok_db (void)
}
status = EFI_ACCESS_DENIED;
} else {
- if (*(UINT8 *)MokDBState == 1) {
+ if (MokDBState == 1) {
ignore_db = 1;
}
}
- FreePool(MokDBState);
-
return status;
}