mirror of
https://github.com/ipxe/ipxe
synced 2026-01-30 04:58:12 +03:00
[efi] Fix Coverity warning about unintended sign extension
The result of multiplying a uint16_t by another uint16_t will be a
signed int. Comparing this against a size_t will perform an unwanted
sign extension.
Fix by explicitly casting e_phnum to an unsigned int, thereby matching
the data type used for the loop index variable (and avoiding the
unwanted sign extension).
This mirrors wimboot commit 15f6162 ("[efi] Fix Coverity warning about
unintended sign extension").
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -440,8 +440,8 @@ static void read_elf_file ( const char *name, struct elf_file *elf ) {
|
|||||||
|
|
||||||
/* Check program headers */
|
/* Check program headers */
|
||||||
if ( ( elf->len < ehdr->e_phoff ) ||
|
if ( ( elf->len < ehdr->e_phoff ) ||
|
||||||
( ( elf->len - ehdr->e_phoff ) < ( ehdr->e_phnum *
|
( ( elf->len - ehdr->e_phoff ) <
|
||||||
ehdr->e_phentsize ) ) ) {
|
( ( ( unsigned int ) ehdr->e_phnum ) * ehdr->e_phentsize ) ) ) {
|
||||||
eprintf ( "ELF program headers outside file in %s\n", name );
|
eprintf ( "ELF program headers outside file in %s\n", name );
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user