summaryrefslogtreecommitdiff
path: root/lib/variables.c
diff options
context:
space:
mode:
authorMathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>2015-05-06 09:49:41 -0400
committerMathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>2015-05-06 09:49:41 -0400
commita14921c5944c340056312f2f5b1728d698f628b1 (patch)
tree110242b91b3ade02e586bd65b9aedb05511bd34a /lib/variables.c
parent72bb39c0237f8bcc3afa8b623e8b097eec6d69cd (diff)
parent7361f67dbd7f7fe98a807d3d12f90a87262124d6 (diff)
downloadefi-boot-shim-a14921c5944c340056312f2f5b1728d698f628b1.tar.gz
efi-boot-shim-a14921c5944c340056312f2f5b1728d698f628b1.zip
Import upstream version 0.8
Diffstat (limited to 'lib/variables.c')
-rw-r--r--lib/variables.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/variables.c b/lib/variables.c
index 81bd34db..59d7d054 100644
--- a/lib/variables.c
+++ b/lib/variables.c
@@ -139,7 +139,7 @@ SetSecureVariable(CHAR16 *var, UINT8 *Data, UINTN len, EFI_GUID owner,
/* Microsoft request: Bugs in some UEFI platforms mean that PK or any
* other secure variable can be updated or deleted programmatically,
* so prevent */
- if (!variable_is_setupmode())
+ if (!variable_is_setupmode(1))
return EFI_SECURITY_VIOLATION;
if (createtimebased) {
@@ -224,7 +224,7 @@ get_variable_attr(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner,
return efi_status;
*data = AllocateZeroPool(*len);
- if (!data)
+ if (!*data)
return EFI_OUT_OF_RESOURCES;
efi_status = uefi_call_wrapper(RT->GetVariable, 5, var, &owner,
@@ -279,14 +279,17 @@ find_in_variable_esl(CHAR16* var, EFI_GUID owner, UINT8 *key, UINTN keylen)
}
int
-variable_is_setupmode(void)
+variable_is_setupmode(int default_return)
{
/* set to 1 because we return true if SetupMode doesn't exist */
- UINT8 SetupMode = 1;
+ UINT8 SetupMode = default_return;
UINTN DataSize = sizeof(SetupMode);
+ EFI_STATUS status;
- uefi_call_wrapper(RT->GetVariable, 5, L"SetupMode", &GV_GUID, NULL,
- &DataSize, &SetupMode);
+ status = uefi_call_wrapper(RT->GetVariable, 5, L"SetupMode", &GV_GUID, NULL,
+ &DataSize, &SetupMode);
+ if (EFI_ERROR(status))
+ return default_return;
return SetupMode;
}
@@ -297,10 +300,13 @@ variable_is_secureboot(void)
/* return false if variable doesn't exist */
UINT8 SecureBoot = 0;
UINTN DataSize;
+ EFI_STATUS status;
DataSize = sizeof(SecureBoot);
- uefi_call_wrapper(RT->GetVariable, 5, L"SecureBoot", &GV_GUID, NULL,
- &DataSize, &SecureBoot);
+ status = uefi_call_wrapper(RT->GetVariable, 5, L"SecureBoot", &GV_GUID, NULL,
+ &DataSize, &SecureBoot);
+ if (EFI_ERROR(status))
+ return 0;
return SecureBoot;
}