]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
mkimage: fix unintended sign extension
authorAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 9 Jan 2016 18:05:44 +0000 (21:05 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 9 Jan 2016 18:05:44 +0000 (21:05 +0300)
Found by: Coverity scan.
CID: 73691, 73717

util/grub-mkimagexx.c

index a1ddc626922892de30276b4349184107333cbbfa..0e0c6f7a1a6c5fe9c0e05d5cdfafa823f03e6faa 100644 (file)
@@ -1465,7 +1465,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
   section_entsize = grub_target_to_host16 (e->e_shentsize);
   num_sections = grub_target_to_host16 (e->e_shnum);
 
-  if (kernel_size < section_offset + section_entsize * num_sections)
+  if (kernel_size < section_offset + (grub_uint32_t) section_entsize * num_sections)
     grub_util_error (_("premature end of file %s"), kernel_path);
 
   sections = (Elf_Shdr *) (kernel_img + section_offset);