From d6655d9995e3fa9a2318261ec3ef5fc54996f69c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 20 Apr 2017 16:40:30 +0200 Subject: Avoid signed/unsigned comparison Some compilers implicitly cast the result of uint_fast16_t * uint_fast16_t to something signed and then complain about the comparison to (unsigned) size_t. Casting phnum to size_t is a good idea anyway as 16bit multiplication can easily overflow and we are not checking for this. Signed-off-by: Ulf Hermann --- libdwfl/ChangeLog | 4 ++++ libdwfl/elf-from-memory.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 92043209..9de28778 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,7 @@ +2017-04-20 Ulf Hermann + + * elf-from-memory.c: Explicitly cast phnum to size_t. + 2017-04-20 Ulf Hermann * dwfl_module_getdwarf.c: Check shnum for 0 before subtracting from diff --git a/libdwfl/elf-from-memory.c b/libdwfl/elf-from-memory.c index dd42e954..12a0a1be 100644 --- a/libdwfl/elf-from-memory.c +++ b/libdwfl/elf-from-memory.c @@ -172,7 +172,7 @@ elf_from_remote_memory (GElf_Addr ehdr_vma, { /* Read in the program headers. */ - if (initial_bufsize < phnum * phentsize) + if (initial_bufsize < (size_t)phnum * phentsize) { unsigned char *newbuf = realloc (buffer, phnum * phentsize); if (newbuf == NULL) -- cgit v1.2.1