Skip to content

Commit

Permalink
set_sbat_uefi_variable(): align some decisions that are off-by-one.
Browse files Browse the repository at this point in the history
Fix a couple of small off-by-one errors in the SBAT variable initial
setup and validation path.

Signed-off-by: Peter Jones <pjones@redhat.com>
  • Loading branch information
vathpela authored and martinezjavier committed Mar 12, 2021
1 parent b3b5185 commit 2a2ae40
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sbat.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ 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,
sbatsize >= strlen(SBAT_VAR_SIG "1") &&
strncmp((const char *)sbat, SBAT_VAR_SIG,
strlen(SBAT_VAR_SIG))) {
dprint("SBAT variable is %d bytes, attributes are 0x%08x\n",
sbatsize, attributes);
Expand All @@ -348,7 +348,7 @@ set_sbat_uefi_variable(void)

/* set variable */
efi_status = set_variable(SBAT_VAR_NAME, SHIM_LOCK_GUID, SBAT_VAR_ATTRS,
sizeof(SBAT_VAR), SBAT_VAR);
sizeof(SBAT_VAR)-1, SBAT_VAR);
if (EFI_ERROR(efi_status)) {
dprint(L"SBAT variable writing failed %r\n", efi_status);
return efi_status;
Expand Down

0 comments on commit 2a2ae40

Please sign in to comment.