Skip to content
Snippets Groups Projects
Commit b6e9e097 authored by Jonathan Gray's avatar Jonathan Gray Committed by Alexander Graf
Browse files

efi_loader: initialise partition_signature memory


Zero partition_signature in the efi_device_path_hard_drive_path
structure when signature_type is 0 (no signature) as required by the
UEFI specification.

This is required so that efi_dp_match() will work as expected
when doing memcmp() comparisons.  Previously uninitialised memory
would cause it not match nodes when it should have when the signature
type was not GUID.

Corrects a problem where the loaded image protocol would not return a
device path with MEDIA_DEVICE causing the OpenBSD bootloader to fail
on rpi_3 and other targets.

v2: Also handle signature_type 1 (MBR) as described in the specification

Signed-off-by: default avatarJonathan Gray <jsg@jsg.id.au>
Tested-by: default avatarArtturi Alm <artturi.alm@gmail.com>
Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
parent ebb4dd5b
No related branches found
No related tags found
No related merge requests found
...@@ -428,10 +428,27 @@ static void *dp_part_fill(void *buf, struct blk_desc *desc, int part) ...@@ -428,10 +428,27 @@ static void *dp_part_fill(void *buf, struct blk_desc *desc, int part)
hddp->partmap_type = 2; hddp->partmap_type = 2;
else else
hddp->partmap_type = 1; hddp->partmap_type = 1;
hddp->signature_type = desc->sig_type;
if (hddp->signature_type != 0) switch (desc->sig_type) {
case SIG_TYPE_NONE:
default:
hddp->signature_type = 0;
memset(hddp->partition_signature, 0,
sizeof(hddp->partition_signature));
break;
case SIG_TYPE_MBR:
hddp->signature_type = 1;
memset(hddp->partition_signature, 0,
sizeof(hddp->partition_signature));
memcpy(hddp->partition_signature, &desc->mbr_sig,
sizeof(desc->mbr_sig));
break;
case SIG_TYPE_GUID:
hddp->signature_type = 2;
memcpy(hddp->partition_signature, &desc->guid_sig, memcpy(hddp->partition_signature, &desc->guid_sig,
sizeof(hddp->partition_signature)); sizeof(hddp->partition_signature));
break;
}
buf = &hddp[1]; buf = &hddp[1];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment