]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/ada-lang.c
[Ada] Buffer overflow in ada_unpack_from_contents
authorJoel Brobecker <brobecker@adacore.com>
Fri, 9 Oct 2015 21:15:16 +0000 (14:15 -0700)
committerJoel Brobecker <brobecker@adacore.com>
Fri, 9 Oct 2015 21:33:28 +0000 (14:33 -0700)
commit0cafa88cc03786fb5794ca53e987e45fd09621f8
treee77b1ba06f4c4402322d2cf6d8eb1f4c5df3b6cf
parent220475ed8b0c1ef7b4eabf64bcc723e14fd78209
[Ada] Buffer overflow in ada_unpack_from_contents

This patch fixes a buffer overflow in ada_unpack_from_contents
caused by one of the previous commits. This happens when trying
to print the value of an array of variant records.

The overflow happens while trying to print one element of the array.
Because the size of each element in the array is variable, the array
has a DWARF byte_stride attribute, which makes us treat the array
as if it was packed. And during the extraction of each array element,
we try to unpack an object using the array's byte stride as the size,
into an element whose size is actually less than the stride.

This patch fixes the issue by overriding the byte-stride with
the actual element's length.

gdb/ChangeLog:

        * ada-lang.c (ada_value_primitive_packed_val): Move
        src_len variable to local block where used.  Override
        BIT_SIZE if bigger than size of resolved type.
gdb/ChangeLog
gdb/ada-lang.c