]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
elflint: Allow zero sized sections at (filesz) end of segment.
authorMark Wielaard <mjw@redhat.com>
Wed, 9 May 2012 09:27:44 +0000 (11:27 +0200)
committerMark Wielaard <mjw@redhat.com>
Wed, 9 May 2012 09:28:43 +0000 (11:28 +0200)
src/ChangeLog
src/elflint.c

index cae5e6b30711c4aabfd3c35590d465a392c703b5..af1d92bd767cb404d09724e8ab830a456d58c3af 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-09  Roland McGrath  <roland@hack.frob.com>
+
+       * elflint (check_sections): Allow zero sized sections at (filesz) end
+       of segment. And make check overflow-proofed.
+
 2012-04-24  Mark Wielaard  <mjw@redhat.com>
 
        * readelf.c (print_ops): Add DW_OP_GNU_push_tls_address,
index a03caac1deaa65b2bb3323889b598964b519701e..7c56069434698a2179476580fe7e9dd2cd258ac8 100644 (file)
@@ -3716,8 +3716,10 @@ section [%2zu] '%s' is both executable and writable\n"),
                    || (phdr->p_type == PT_TLS
                        && (shdr->sh_flags & SHF_TLS) != 0))
                && phdr->p_offset <= shdr->sh_offset
-               && (phdr->p_offset + phdr->p_filesz > shdr->sh_offset
-                   || (phdr->p_offset + phdr->p_memsz > shdr->sh_offset
+               && ((shdr->sh_offset - phdr->p_offset <= phdr->p_filesz
+                    && (shdr->sh_offset - phdr->p_offset < phdr->p_filesz
+                        || shdr->sh_size == 0))
+                   || (shdr->sh_offset - phdr->p_offset < phdr->p_memsz
                        && shdr->sh_type == SHT_NOBITS)))
              {
                /* Found the segment.  */