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>
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
left shift.
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';