summaryrefslogtreecommitdiff
path: root/sbat.c
diff options
context:
space:
mode:
authorJan Setje-Eilers <jan.setjeeilers@oracle.com>2021-03-26 21:19:14 -0700
committerPeter Jones <pjones@redhat.com>2021-03-27 18:47:31 -0400
commit08a0ce01dbe9945287f37a9b139b25f46c53f878 (patch)
tree6cdf4a08eaa95153c1706dfa769fbfd0a428b9b5 /sbat.c
parentab934ec5874235aaf2204570c1e0dc6a1ab75d26 (diff)
downloadefi-boot-shim-08a0ce01dbe9945287f37a9b139b25f46c53f878.tar.gz
efi-boot-shim-08a0ce01dbe9945287f37a9b139b25f46c53f878.zip
Move the check for the SBAT variable properties to its own function.
This moves the check for the SBAT variable's attributes and contents into its own function, so that test cases can be written against it. Signed-off-by: Jan Setje-Eilers <jan.setjeeilers@oracle.com>
Diffstat (limited to 'sbat.c')
-rw-r--r--sbat.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sbat.c b/sbat.c
index 89c08417..7bd0e4ec 100644
--- a/sbat.c
+++ b/sbat.c
@@ -304,6 +304,14 @@ check_sbat_var_attributes(UINT32 attributes)
#endif
}
+bool
+preserve_sbat_uefi_variable(UINT8 *sbat, UINTN sbatsize, UINT32 attributes)
+{
+ return check_sbat_var_attributes(attributes) &&
+ sbatsize >= strlen(SBAT_VAR_SIG "1") &&
+ strncmp((const char *)sbat, SBAT_VAR_SIG, strlen(SBAT_VAR_SIG));
+}
+
EFI_STATUS
set_sbat_uefi_variable(void)
{
@@ -323,10 +331,7 @@ set_sbat_uefi_variable(void)
*/
if (EFI_ERROR(efi_status)) {
dprint(L"SBAT read failed %r\n", efi_status);
- } else if (check_sbat_var_attributes(attributes) &&
- sbatsize >= strlen(SBAT_VAR_SIG "1") &&
- strncmp((const char *)sbat, SBAT_VAR_SIG,
- strlen(SBAT_VAR_SIG))) {
+ } else if (preserve_sbat_uefi_variable(sbat, sbatsize, attributes)) {
dprint("SBAT variable is %d bytes, attributes are 0x%08x\n",
sbatsize, attributes);
FreePool(sbat);