]> git.proxmox.com Git - grub2.git/commitdiff
loader/multiboot: fix unintended sign extension
authorAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 9 Jan 2016 16:58:51 +0000 (19:58 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 9 Jan 2016 16:58:51 +0000 (19:58 +0300)
Found by: Coveruty scan.
CID: 73700, 73763

grub-core/loader/multiboot_elfxx.c

index 6a220bdc17bb38b20241a16bf0fbda0791ab7d7e..a7bebcb3c8a96d0a437f41cba95aa3319f9fb0cf 100644 (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;