partmap/msdos: Add missing grub_malloc() failure check
This patch adds a NULL check after grub_malloc() call. Missing a failure check after calling grub_malloc() can lead to undefined behavior. If the allocation fails and returns NULL subsequent dereferencing or writing to the pointer will likely result in a runtime error such as a segmentation fault. Signed-off-by: Avnish Chouhan <avnish@linux.ibm.com> Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
c0d2f76d55
commit
4cc22937e7
@ -348,6 +348,9 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
|
|||||||
* area.
|
* area.
|
||||||
*/
|
*/
|
||||||
embed_signature_check = grub_malloc (GRUB_DISK_SECTOR_SIZE);
|
embed_signature_check = grub_malloc (GRUB_DISK_SECTOR_SIZE);
|
||||||
|
if (embed_signature_check == NULL)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
for (i = 0; i < *nsectors; i++)
|
for (i = 0; i < *nsectors; i++)
|
||||||
{
|
{
|
||||||
if (grub_disk_read (disk, (*sectors)[i], 0, GRUB_DISK_SECTOR_SIZE,
|
if (grub_disk_read (disk, (*sectors)[i], 0, GRUB_DISK_SECTOR_SIZE,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user