[PATCH] libelf: Free and clear rawdata_base and zdata_base consistently

Mark Wielaard mark@klomp.org
Wed Aug 2 16:06:41 GMT 2023


Hi,

On Sun, Jul 30, 2023 at 05:44:20PM +0200, Mark Wielaard wrote:
> There could be a leak if a program called elf_strptr on a compressed
> section, but the program never requests the (uncompressed) section data,
> but does explicitly (re)compress that same section data.
> 
> Fix this by explicitly always freeing and clearing the zdata_base
> and rawdata_base in __libelf_reset_rawdata and elf_compress. Also
> clear zdata_base in elf_end so the pointer isn't indeterminate when
> it is being used in a later comparison against rawdata_base.
> 
> 	* libelf/elf_compress.c (elf_compress): Explicitly free
> 	zdata_base before clearing.
> 	(__libelf_reset_rawdata): Free zdata_base if it isn't
> 	(going to be) used for rawdata_base. Explicitly clear
> 	rawdata_base and zdata_base after free.
> 	* libelf/elf_end.c (elf_end): Clear zdata_base after free.

Pushed.

Mark


More information about the Elfutils-devel mailing list