[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 33/41] linux-user/elfload: Avoid leaking interp_name using GLib me
From: |
Peter Maydell |
Subject: |
[PULL 33/41] linux-user/elfload: Avoid leaking interp_name using GLib memory API |
Date: |
Tue, 20 Oct 2020 16:56:48 +0100 |
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
Fix an unlikely memory leak in load_elf_image().
Fixes: bf858897b7 ("linux-user: Re-use load_elf_image for the main binary.")
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20201016184207.786698-5-richard.henderson@linaro.org
Message-Id: <20201003174944.1972444-1-f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
linux-user/elfload.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index f6022fd7049..1a3150df7c0 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2584,13 +2584,13 @@ static void load_elf_image(const char *image_name, int
image_fd,
info->brk = vaddr_em;
}
} else if (eppnt->p_type == PT_INTERP && pinterp_name) {
- char *interp_name;
+ g_autofree char *interp_name = NULL;
if (*pinterp_name) {
errmsg = "Multiple PT_INTERP entries";
goto exit_errmsg;
}
- interp_name = malloc(eppnt->p_filesz);
+ interp_name = g_malloc(eppnt->p_filesz);
if (!interp_name) {
goto exit_perror;
}
@@ -2609,7 +2609,7 @@ static void load_elf_image(const char *image_name, int
image_fd,
errmsg = "Invalid PT_INTERP entry";
goto exit_errmsg;
}
- *pinterp_name = interp_name;
+ *pinterp_name = g_steal_pointer(&interp_name);
#ifdef TARGET_MIPS
} else if (eppnt->p_type == PT_MIPS_ABIFLAGS) {
Mips_elf_abiflags_v0 abiflags;
@@ -2961,7 +2961,7 @@ int load_elf_binary(struct linux_binprm *bprm, struct
image_info *info)
if (elf_interpreter) {
info->load_bias = interp_info.load_bias;
info->entry = interp_info.entry;
- free(elf_interpreter);
+ g_free(elf_interpreter);
}
#ifdef USE_ELF_CORE_DUMP
--
2.20.1
- [PULL 23/41] target/arm: Make the t32 insn[25:23]=111 group non-overlapping, (continued)
- [PULL 23/41] target/arm: Make the t32 insn[25:23]=111 group non-overlapping, Peter Maydell, 2020/10/20
- [PULL 24/41] target/arm: Don't allow BLX imm for M-profile, Peter Maydell, 2020/10/20
- [PULL 25/41] target/arm: Implement v8.1M branch-future insns (as NOPs), Peter Maydell, 2020/10/20
- [PULL 26/41] target/arm: Implement v8.1M low-overhead-loop instructions, Peter Maydell, 2020/10/20
- [PULL 27/41] target/arm: Fix has_vfp/has_neon ID reg squashing for M-profile, Peter Maydell, 2020/10/20
- [PULL 28/41] target/arm: Allow M-profile CPUs with FP16 to set FPSCR.FP16, Peter Maydell, 2020/10/20
- [PULL 31/41] linux-user: Set PAGE_TARGET_1 for TARGET_PROT_BTI, Peter Maydell, 2020/10/20
- [PULL 29/41] target/arm: Implement FPSCR.LTPSIZE for M-profile LOB extension, Peter Maydell, 2020/10/20
- [PULL 30/41] linux-user/aarch64: Reset btype for signals, Peter Maydell, 2020/10/20
- [PULL 32/41] include/elf: Add defines related to GNU property notes for AArch64, Peter Maydell, 2020/10/20
- [PULL 33/41] linux-user/elfload: Avoid leaking interp_name using GLib memory API,
Peter Maydell <=
- [PULL 35/41] linux-user/elfload: Adjust iteration over phdr, Peter Maydell, 2020/10/20
- [PULL 36/41] linux-user/elfload: Move PT_INTERP detection to first loop, Peter Maydell, 2020/10/20
- [PULL 38/41] linux-user/elfload: Use Error for load_elf_interp, Peter Maydell, 2020/10/20
- [PULL 34/41] linux-user/elfload: Fix coding style in load_elf_image, Peter Maydell, 2020/10/20
- [PULL 37/41] linux-user/elfload: Use Error for load_elf_image, Peter Maydell, 2020/10/20
- [PULL 39/41] linux-user/elfload: Parse NT_GNU_PROPERTY_TYPE_0 notes, Peter Maydell, 2020/10/20
- [PULL 40/41] linux-user/elfload: Parse GNU_PROPERTY_AARCH64_FEATURE_1_AND, Peter Maydell, 2020/10/20
- [PULL 41/41] tests/tcg/aarch64: Add bti smoke tests, Peter Maydell, 2020/10/20
- Re: [PULL 00/41] target-arm queue, Philippe Mathieu-Daudé, 2020/10/20
- Re: [PULL 00/41] target-arm queue, no-reply, 2020/10/20