diff options
author | 2015-02-28 22:57:40 +0000 | |
---|---|---|
committer | 2015-02-28 22:57:40 +0000 | |
commit | 480966da3e22c65ca0174e9384c17f4a4cc30f32 (patch) | |
tree | 8a1a7a04bf0423271ada96b139779044c1b866ef /paxelf.h | |
parent | add a fuzz target (diff) | |
download | pax-utils-480966da3e22c65ca0174e9384c17f4a4cc30f32.tar.gz pax-utils-480966da3e22c65ca0174e9384c17f4a4cc30f32.tar.bz2 pax-utils-480966da3e22c65ca0174e9384c17f4a4cc30f32.zip |
scanelf: check shdrs are valid before using them
Diffstat (limited to 'paxelf.h')
-rw-r--r-- | paxelf.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1,7 +1,7 @@ /* * Copyright 2005-2012 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.60 2014/06/18 03:16:52 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.61 2015/02/28 22:57:40 vapier Exp $ * * Copyright 2005-2012 Ned Ludd - <solar@gentoo.org> * Copyright 2005-2012 Mike Frysinger - <vapier@gentoo.org> @@ -40,6 +40,13 @@ typedef struct { #define SYM32(ptr) ((Elf32_Sym *)(ptr)) #define SYM64(ptr) ((Elf64_Sym *)(ptr)) +#define VALID_SHDR(elf, shdr) \ + (shdr && \ + EGET(shdr->sh_type) != SHT_NOBITS && \ + EGET(shdr->sh_offset) < (uint64_t)elf->len && \ + EGET(shdr->sh_size) < (uint64_t)elf->len && \ + EGET(shdr->sh_offset) < elf->len - EGET(shdr->sh_size)) + /* prototypes */ extern char *pax_short_hf_flags(unsigned long flags); extern char *pax_short_pf_flags(unsigned long flags); |