[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libunwind-devel] [PATCH] Check mapped ELF file headers
From: |
Zachary T Welch |
Subject: |
[Libunwind-devel] [PATCH] Check mapped ELF file headers |
Date: |
Wed, 17 Nov 2010 21:14:04 -0800 |
Some entries in /proc/<pid>/maps are not ELF files, so add checks
in elf_map_image() to ensure mapped files have a valid ELF header.
Signed-off-by: Zachary T Welch <address@hidden>
---
src/elfxx.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/elfxx.h b/src/elfxx.h
index 7742806..cdc3f58 100644
--- a/src/elfxx.h
+++ b/src/elfxx.h
@@ -46,6 +46,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
static inline int
elf_map_image (struct elf_image *ei, const char *path)
{
+ Elf_W (Ehdr) *ehdr;
struct stat stat;
int fd;
@@ -65,6 +66,13 @@ elf_map_image (struct elf_image *ei, const char *path)
if (ei->image == MAP_FAILED)
return -1;
+ ehdr = ei->image;
+ if (strncmp(ehdr->e_ident, "\x7f" "ELF", 4) != 0)
+ return -1;
+
+ if (ehdr->e_version == EV_NONE || ehdr->e_version > EV_CURRENT)
+ return -1;
+
return 0;
}
--
1.7.2.2
- [Libunwind-devel] [PATCH] Check mapped ELF file headers,
Zachary T Welch <=