summaryrefslogtreecommitdiffstats
path: root/libelf
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2024-01-21 20:54:39 +0100
committerMark Wielaard <[email protected]>2024-01-30 16:36:14 +0100
commitaba8520b1e43d85f52431251232f96384e704cb5 (patch)
treef50ecf6c83646dd95bea419e27488e907fa517d4 /libelf
parent7554d41cd3784a321751c9ac430ad123f6c8cc1e (diff)
libdwfl: Add some extra space to buffer to read kernel image header
GCC 14 notices we play some tricks with the array into which we try to read the kernel image header. image-header.c: In function ‘__libdw_image_header’: image-header.c:77:18: error: array subscript -496 is outside array bounds of ‘char[96]’ [-Werror=array-bounds=] 77 | header = header_buffer - H_START; | ^ image-header.c:67:12: note: at offset -496 into object ‘header_buffer’ of size 96 67 | char header_buffer[H_READ_SIZE]; | ^~~~~~~~~~~~~ GCC is correct. The new header pointer is before the actually buffer we want to read from. Later in the code we "correct" the address again by adding the "offset" off the elements we want to read. Such pointer arithmetic is technically invalid. Make it valid by making the buffer a little bigger, so all pointer arithmetic stays inside the header_buffer. This does waste 496 bytes on the stack at the front of the buffer that is never used. * libdwfl/image-header.c (__libdw_image_header): Add H_START to header_buffer size and return Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libelf')
0 files changed, 0 insertions, 0 deletions