From d98f2d32d1e663bfb7a069a1623de15df6be765d Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Sat, 28 Feb 2015 16:07:55 -0300 Subject: [PATCH] Avoid sign-extension error on multiplication Do not promote "idx * elf->header.section.entry_size" to int. Explicitly cast the result to uint64_t so it's zero-extended. --- libkmod/libkmod-elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libkmod/libkmod-elf.c b/libkmod/libkmod-elf.c index 2f50ad2d..90da89ae 100644 --- a/libkmod/libkmod-elf.c +++ b/libkmod/libkmod-elf.c @@ -218,7 +218,7 @@ static inline const void *elf_get_section_header(const struct kmod_elf *elf, uin return NULL; } return elf_get_mem(elf, elf->header.section.offset + - idx * elf->header.section.entry_size); + (uint64_t)(idx * elf->header.section.entry_size)); } static inline int elf_get_section_info(const struct kmod_elf *elf, uint16_t idx, uint64_t *offset, uint64_t *size, uint32_t *nameoff) -- 2.47.3