efiemu/loadcore: Add grub_calloc() failure check
Add a failure check after grub_calloc() call. If grub_calloc() fails, e.g., due to memory allocation failure, it returns NULL. Then using grub_efiemu_elfsyms, which will be NULL, later will result in a NULL pointer dereference. 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
641646376b
commit
09c512b8fa
@ -203,6 +203,9 @@ grub_efiemu_count_symbols (const Elf_Ehdr *e)
|
|||||||
grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *)
|
grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *)
|
||||||
grub_calloc (grub_efiemu_nelfsyms, sizeof (struct grub_efiemu_elf_sym));
|
grub_calloc (grub_efiemu_nelfsyms, sizeof (struct grub_efiemu_elf_sym));
|
||||||
|
|
||||||
|
if (grub_efiemu_elfsyms == NULL)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
/* Relocators */
|
/* Relocators */
|
||||||
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
|
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
|
||||||
i < e->e_shnum;
|
i < e->e_shnum;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user