Bug 26375 - A memory leak in get_data
Summary: A memory leak in get_data
Status: RESOLVED WORKSFORME
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.34
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-12 10:22 UTC by 15664243668
Modified: 2020-08-12 12:24 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
PoC (444 bytes, application/octet-stream)
2020-08-12 10:22 UTC, 15664243668
Details

Note You need to log in before you can comment on or make changes to this bug.
Description 15664243668 2020-08-12 10:22:24 UTC
Created attachment 12764 [details]
PoC

I have found a memory leak in get_data of Binutils-2.34. This bug is triggered as
$./readelf -a PoC
I compile the binutils-2.34 to the 64-bit LSB version with AddressSanitizer in Ubuntu 16.04 and print the debug information.

=================================================================
==30101==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2053 byte(s) in 1 object(s) allocated from:
    #0 0x7f390d037b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
    #1 0x55f13c7587a3 in get_data /home/ubuntu/yuetai/test_programs/binutils-2.34/binutils/readelf.c:439
    #2 0x55f13c9f254f  (/home/ubuntu/yuetai/test_programs/binutils-2.34/binutils-install/bin/readelf+0x39554f)

SUMMARY: AddressSanitizer: 2053 byte(s) leaked in 1 allocation(s).

The PoC file is in attachment.
Comment 1 Alan Modra 2020-08-12 12:24:12 UTC
Already fixed on master