blob: 8b03c0ea6ba535a42f2515ca2b07830a7f514e8f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
From d68822e93c57c3fbb77b93eada5986d2240157c2 Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Thu, 16 Aug 2018 09:58:26 +0800
Subject: [PATCH] libelf/elf_end.c: check data_list.data.d.d_buf before free it
The one which actually saves the data is data_list.data.d.d_buf, so check it
before free rawdata_base.
This can fix a segmentation fault when prelink libqb_1.0.3:
prelink: /usr/lib/libqb.so.0.18.2: Symbol section index outside of section numbers
The segmentation fault happens when prelink call elf_end().
Upstream-Status: Submitted [https://sourceware.org/ml/elfutils-devel/2018-q3/msg00065.html]
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
libelf/elf_end.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libelf/elf_end.c b/libelf/elf_end.c
index 160f0b8..5388e80 100644
--- a/libelf/elf_end.c
+++ b/libelf/elf_end.c
@@ -165,9 +165,10 @@ elf_end (Elf *elf)
/* The section data is allocated if we couldn't mmap
the file. Or if we had to decompress. */
- if (elf->map_address == NULL
+ if ((elf->map_address == NULL
|| scn->rawdata_base == scn->zdata_base
|| (scn->flags & ELF_F_MALLOCED) != 0)
+ && (scn->data_list.data.d.d_buf != NULL))
free (scn->rawdata_base);
/* Free the list of data buffers for the section.
--
2.7.4
|