Skip to content

Commit 09c512b

Browse files
Avnish ChouhanDaniel Kiper
authored andcommitted
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>
1 parent 6416463 commit 09c512b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

grub-core/efiemu/loadcore.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ grub_efiemu_count_symbols (const Elf_Ehdr *e)
203203
grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *)
204204
grub_calloc (grub_efiemu_nelfsyms, sizeof (struct grub_efiemu_elf_sym));
205205

206+
if (grub_efiemu_elfsyms == NULL)
207+
return grub_errno;
208+
206209
/* Relocators */
207210
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
208211
i < e->e_shnum;

0 commit comments

Comments
 (0)