]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: handle_core_item make sure variable length array isn't zero size.
authorMark Wielaard <mjw@redhat.com>
Tue, 22 Apr 2014 21:26:34 +0000 (23:26 +0200)
committerMark Wielaard <mjw@redhat.com>
Thu, 24 Apr 2014 09:33:54 +0000 (11:33 +0200)
The printed array should have at least space for the terminating zero char.
Found by gcc -fsanitize=undefined while running run-readelf-vmcoreinfo.sh.
runtime error: variable length array bound evaluates to non-positive value 0

Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/ChangeLog
src/readelf.c

index 874e2553e8db85e191e82a44551ed68882f510ad..28e52f94b3f2f0c139a158ef838d8030f8742dc7 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-22  Mark Wielaard  <mjw@redhat.com>
+
+       * readelf.c (handle_core_item): Make sure variable length array
+       contains at least enough space for terminating zero char.
+
 2014-04-22  Mark Wielaard  <mjw@redhat.com>
 
        * readelf.c (print_gdb_index_section): Use unsigned int for 31 bits
index da1bf73ab9cd65c87e22aa44a56fb865aaeab9b2..697a361b8be2e5605fcae4fe6b3520e96352ec1f 100644 (file)
@@ -8128,7 +8128,7 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void *desc,
       const unsigned int bias = item->format == 'b';
 
       {
-       char printed[(negate ? nbits - pop : pop) * 16];
+       char printed[(negate ? nbits - pop : pop) * 16 + 1];
        char *p = printed;
        *p = '\0';