mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 00:47:26 +00:00
disk: Extend disk_blk_part_validate() with range checking
Check whether access is out of bounds of the partition and return an error. This way there is no danger of esp. write or erase outside of the confines of partition. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
This commit is contained in:
parent
2bc0dfef9f
commit
bfd98b9a63
1 changed files with 8 additions and 0 deletions
|
@ -27,9 +27,17 @@
|
|||
*/
|
||||
static int disk_blk_part_validate(struct udevice *dev, lbaint_t start, lbaint_t blkcnt)
|
||||
{
|
||||
struct disk_part *part = dev_get_uclass_plat(dev);
|
||||
|
||||
if (device_get_uclass_id(dev) != UCLASS_PARTITION)
|
||||
return -ENOSYS;
|
||||
|
||||
if (start >= part->gpt_part_info.size)
|
||||
return -E2BIG;
|
||||
|
||||
if ((start + blkcnt) > part->gpt_part_info.size)
|
||||
return -ERANGE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue