summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbat.c6
-rw-r--r--test-sbat.c10
2 files changed, 10 insertions, 6 deletions
diff --git a/sbat.c b/sbat.c
index 5821475b..e102914c 100644
--- a/sbat.c
+++ b/sbat.c
@@ -139,7 +139,7 @@ cleanup_sbat_var(list_t *entries)
list_for_each_safe(pos, tmp, entries) {
entry = list_entry(pos, struct sbat_var_entry, list);
- if ((uintptr_t)entry < (uintptr_t)first && entry != NULL)
+ if (first == NULL || (uintptr_t)entry < (uintptr_t)first)
first = entry;
list_del(&entry->list);
@@ -239,10 +239,10 @@ parse_sbat_var_data(list_t *entry_list, UINT8 *data, UINTN datasize)
INIT_LIST_HEAD(entry_list);
- entries = (struct sbat_var_entry **)strtab;
- strtab += sizeof(struct sbat_var_entry *) * n;
entry = (struct sbat_var_entry *)strtab;
strtab += sizeof(struct sbat_var_entry) * n;
+ entries = (struct sbat_var_entry **)strtab;
+ strtab += sizeof(struct sbat_var_entry *) * n;
n = 0;
list_for_each(pos, &csv) {
diff --git a/test-sbat.c b/test-sbat.c
index 8f361da6..e97c3d87 100644
--- a/test-sbat.c
+++ b/test-sbat.c
@@ -903,6 +903,7 @@ test_parse_and_verify(void)
struct sbat_section_entry *test_entries[] = {
&test_section_entry1, &test_section_entry2,
};
+ int rc = -1;
status = parse_sbat_section(sbat_section, sizeof(sbat_section)-1,
&n_section_entries, &section_entries);
@@ -941,16 +942,19 @@ test_parse_and_verify(void)
INIT_LIST_HEAD(&sbat_var);
status = parse_sbat_var_data(&sbat_var, sbat_var_alloced, sbat_var_data_size);
+ free(sbat_var_alloced);
if (status != EFI_SUCCESS || list_empty(&sbat_var))
return -1;
status = verify_sbat(n_section_entries, section_entries);
+ assert_equal_goto(status, EFI_SECURITY_VIOLATION, err, "expected %#x got %#x\n");
- assert_equal_return(status, EFI_SECURITY_VIOLATION, -1, "expected %#x got %#x\n");
- cleanup_sbat_var(&sbat_var);
+ rc = 0;
+err:
cleanup_sbat_section_entries(n_section_entries, section_entries);
+ cleanup_sbat_var(&sbat_var);
- return 0;
+ return rc;
}
int