loader/multiboot: fix unintended sign extension

Found by: Coveruty scan.
CID: 73700, 73763
This commit is contained in:
Andrei Borzenkov 2016-01-09 19:58:51 +03:00
parent 9fecb0588e
commit 31f6506c57

View file

@ -72,7 +72,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi
return grub_error (GRUB_ERR_UNKNOWN_OS, N_("this ELF file is not of the right type"));
/* FIXME: Should we support program headers at strange locations? */
if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH)
if (ehdr->e_phoff + (grub_uint32_t) ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH)
return grub_error (GRUB_ERR_BAD_OS, "program header at a too high offset");
phdr_base = (char *) buffer + ehdr->e_phoff;