When map_address is NULL, computing map_address+offset is technically
undefined behavior, and triggers Clang/LLVM warning when using
-fsanitize=pointer-overflow.
Fix this by using uintptr_t to perform computations.
Signed-off-by: Shahriar "Nafi" Rouf
---
libelf/elf_begin.c | 10 +-
1 fi
only resolves the issue for the 64bit ELF case. Just above
> this code is basically the same code for 32bit ELF. That code also
> needs to be fixed.
Sorry I missed that.
Revised patch attached.
Thanks,
--
Paul Pluzhnikov
0001-Fix-computations-with-potentially-NULL-pointer.patch
Description: Binary data
t tried (with gcc) and it seems to not trigger.
This was exposed by Clang (and a close to HEAD Clang at that -- I am
not sure whether released Clang also catches this).
> Looks good. Applied.
Thanks!
Appreciate the speedy reviews.
--
Paul Pluzhnikov
dress,
unsigned char *e_ident,
goto free_and_out;
if (scncnt > 0)
- elf->state.elf64.shdr = (Elf64_Shdr *) (ehdr + e_shoff);
+ elf->state.elf64.shdr = (Elf64_Shdr *) (ehdr + (ptrdiff_t) e_shoff);
for (size_t cnt = 0; cnt < scncnt; ++cnt)
{
--
Paul Pluzhnikov
We have a clang-tidy complaining that uintptr_t is not provided by any
directly included header (it's only provided by a transitively included one).
* libelf/elf_begin.c: Include
Signed-off-by: Paul Pluzhnikov
---
libelf/elf_begin.c | 1 +
1 file changed, 1 insertion(+)
diff --