lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 14 Sep 2017 07:31:45 +0200
From:   Ingo Molnar <mingo@...nel.org>
To:     Josh Poimboeuf <jpoimboe@...hat.com>
Cc:     linux-kernel@...r.kernel.org, Martin Kepplinger <martink@...teo.de>
Subject: Re: [PATCH] tools: objtool: fix memory leak in
 elf_create_rela_section()


* Josh Poimboeuf <jpoimboe@...hat.com> wrote:

> From: Martin Kepplinger <martink@...teo.de>
> 
> Let's free the allocated char array relaname before returning
> in order to avoid leaking memory.
> 
> Signed-off-by: Martin Kepplinger <martink@...teo.de>
> Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
> ---
>  tools/objtool/elf.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> index 6e9f980a7d26..6aacbc31316d 100644
> --- a/tools/objtool/elf.c
> +++ b/tools/objtool/elf.c
> @@ -508,8 +508,12 @@ struct section *elf_create_rela_section(struct elf *elf, struct section *base)
>  	strcat(relaname, base->name);
>  
>  	sec = elf_create_section(elf, relaname, sizeof(GElf_Rela), 0);
> -	if (!sec)
> +	if (!sec) {
> +		free(relaname);
>  		return NULL;
> +	}
> +
> +	free(relaname);

Erm, I'm quite sure if you read this code a second time you'll see how this 
pattern could be improved! ;-)

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ