efi_loader: disk: Sanitize exposed devices
PATCH 1/1 efi_loader: disk: Sanitize exposed devices
When a target device is 0 bytes long, there's no point in exposing it to the user. Let's just skip them.
Also, when an offset is passed into the efi disk creation, we should remove this offset from the total number of sectors we can handle.
This patch fixes both things.
Signed-off-by Alexander Graf <[email protected]>
--- lib/efi_loader/efi_disk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/efi_loader/efi_disk.c +5 -1
@@ -202,6 +202,10 @@ static void efi_disk_add_dev(const char *name,struct efi_device_path_file_path *dp;int objlen =sizeof (*diskobj) + (sizeof (*dp) *2 ); +/* Don't add empty devices */ +if (!desc->lba) +return ; + diskobj =calloc (1 , objlen);/* Fill in object data */
@@ -221,7 +225,7 @@ static void efi_disk_add_dev(const char *name, diskobj->media.media_present =1 ; diskobj->media.block_size = desc->blksz; diskobj->media.io_align = desc->blksz; - diskobj->media.last_block = desc->lba; + diskobj->media.last_block = desc->lba - offset; diskobj->ops.media = &diskobj->media;/* Fill in device path */
Signature · 1 line
2.6.6
Quoted 9 lines · Alexander Graf
When a target device is 0 bytes long, there's no point in exposing it to the user. Let's just skip them.
Also, when an offset is passed into the efi disk creation, we should remove this offset from the total number of sectors we can handle.
This patch fixes both things.
Signed-off-by Alexander Graf <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160809/6096192d/attachment.sig>