]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Avoid signed/unsigned comparison
authorUlf Hermann <ulf.hermann@qt.io>
Thu, 20 Apr 2017 14:40:30 +0000 (16:40 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 27 Apr 2017 18:19:54 +0000 (20:19 +0200)
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 <ulf.hermann@qt.io>
libdwfl/ChangeLog
libdwfl/elf-from-memory.c

index 920432092c738653a8bd93f8c502ae3d4687f146..9de28778a26baed983619d1992275d36ebafbdbf 100644 (file)
@@ -1,3 +1,7 @@
+2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
+
+       * elf-from-memory.c: Explicitly cast phnum to size_t.
+
 2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
 
        * dwfl_module_getdwarf.c: Check shnum for 0 before subtracting from
index dd42e954058979d38ac7d532025382a2e76cc46e..12a0a1be823ddec7d47054dc7f036f1805c01307 100644 (file)
@@ -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)