aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2006-01-10 01:35:06 +0000
committerMike Frysinger <vapier@gentoo.org>2006-01-10 01:35:06 +0000
commit051d4685f1f974ce141f94977f116ef1a30994fd (patch)
tree01e2461d4896ed340d99f0dd718e7565fed9e6b4
parenttighten up the pax_short_pf_flags() code (diff)
downloadpax-utils-051d4685f1f974ce141f94977f116ef1a30994fd.tar.gz
pax-utils-051d4685f1f974ce141f94977f116ef1a30994fd.tar.bz2
pax-utils-051d4685f1f974ce141f94977f116ef1a30994fd.zip
split the pt_load check out into a sep func for easier managing in the future and to shut up openbsd
-rw-r--r--paxelf.c18
-rw-r--r--paxelf.h3
-rw-r--r--pspax.c15
-rw-r--r--scanelf.c11
4 files changed, 34 insertions, 13 deletions
diff --git a/paxelf.c b/paxelf.c
index 93ce760..276c4ea 100644
--- a/paxelf.c
+++ b/paxelf.c
@@ -1,7 +1,7 @@
/*
* Copyright 2003-2006 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.32 2006/01/10 01:32:32 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.33 2006/01/10 01:35:06 vapier Exp $
*
* Copyright 2005-2006 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2006 Mike Frysinger - <vapier@gentoo.org>
@@ -522,3 +522,19 @@ void *elf_findsecbyname(elfobj *elf, const char *name)
return ret;
}
+
+int elf_max_pt_load(elfobj *elf)
+{
+#define MAX_PT_LOAD(B) \
+ if (elf->elf_class == ELFCLASS ## B) { \
+ Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
+ switch (EGET(ehdr->e_ident[EI_OSABI])) { \
+ case ELFOSABI_NONE: \
+ case ELFOSABI_ARM: return 2; \
+ case ELFOSABI_OPENBSD: return 7; \
+ } }
+ MAX_PT_LOAD(32)
+ MAX_PT_LOAD(64)
+
+ return 0;
+}
diff --git a/paxelf.h b/paxelf.h
index a2b86f2..e6d1b99 100644
--- a/paxelf.h
+++ b/paxelf.h
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2006 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.37 2006/01/05 03:12:07 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.38 2006/01/10 01:35:06 vapier Exp $
*
* Copyright 2005-2006 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2006 Mike Frysinger - <vapier@gentoo.org>
@@ -52,6 +52,7 @@ extern const char *get_elfdtype(int type);
extern const char *get_elfshttype(int type);
extern const char *get_elfstttype(int type);
extern void *elf_findsecbyname(elfobj *elf, const char *name);
+extern int elf_max_pt_load(elfobj *elf);
/* PaX flags (to be read in elfhdr.e_flags) */
#define HF_PAX_PAGEEXEC 1 /* 0: Paging based non-exec pages */
diff --git a/pspax.c b/pspax.c
index c90685c..82ab3a9 100644
--- a/pspax.c
+++ b/pspax.c
@@ -21,7 +21,7 @@
#endif
#define PROC_DIR "/proc"
-static const char *rcsid = "$Id: pspax.c,v 1.24 2006/01/05 03:12:07 vapier Exp $";
+static const char *rcsid = "$Id: pspax.c,v 1.25 2006/01/10 01:35:06 vapier Exp $";
#define argv0 "pspax"
@@ -53,7 +53,8 @@ static char *get_proc_name(pid_t pid)
return (str+1);
}
-static int get_proc_maps(pid_t pid) {
+static int get_proc_maps(pid_t pid)
+{
static char str[_POSIX_PATH_MAX];
FILE *fp;
@@ -89,7 +90,8 @@ static int get_proc_maps(pid_t pid) {
return 0;
}
-static int print_executable_mappings(pid_t pid) {
+static int print_executable_mappings(pid_t pid)
+{
static char str[_POSIX_PATH_MAX];
FILE *fp;
@@ -206,12 +208,13 @@ static const char *get_proc_type(pid_t pid)
static char *scanelf_file_phdr(elfobj *elf)
{
static char ret[8];
- unsigned long i, off;
- unsigned char multi_stack, multi_load;
+ unsigned long i, off, multi_stack, multi_load;
+ int max_pt_load;
memcpy(ret, "--- ---\0", 8);
multi_stack = multi_load = 0;
+ max_pt_load = elf_max_pt_load(elf);
if (elf->phdr) {
uint32_t flags;
@@ -224,7 +227,7 @@ static char *scanelf_file_phdr(elfobj *elf)
if (multi_stack++) warnf("%s: multiple PT_GNU_STACK's !?", elf->filename); \
off = 0; \
} else if (EGET(phdr[i].p_type) == PT_LOAD) { \
- if (multi_load++ > 2) warnf("%s: more than 2 PT_LOAD's !?", elf->filename); \
+ if (multi_load++ > max_pt_load) warnf("%s: more than %i PT_LOAD's !?", elf->filename, max_pt_load); \
off = 4; \
} else \
continue; \
diff --git a/scanelf.c b/scanelf.c
index 28e4daa..78c9991 100644
--- a/scanelf.c
+++ b/scanelf.c
@@ -1,7 +1,7 @@
/*
* Copyright 2003-2006 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.98 2006/01/05 03:12:07 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.99 2006/01/10 01:35:06 vapier Exp $
*
* Copyright 2003-2006 Ned Ludd - <solar@gentoo.org>
* Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org>
@@ -9,7 +9,7 @@
#include "paxinc.h"
-static const char *rcsid = "$Id: scanelf.c,v 1.98 2006/01/05 03:12:07 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.99 2006/01/10 01:35:06 vapier Exp $";
#define argv0 "scanelf"
#define IS_MODIFIER(c) (c == '%' || c == '#')
@@ -138,8 +138,8 @@ static char *scanelf_file_phdr(elfobj *elf, char *found_phdr, char *found_relro,
{
static char ret[12];
char *found;
- unsigned long i, shown;
- unsigned char multi_stack, multi_relro, multi_load;
+ unsigned long i, shown, multi_stack, multi_relro, multi_load;
+ int max_pt_load;
if (!show_phdr) return NULL;
@@ -147,6 +147,7 @@ static char *scanelf_file_phdr(elfobj *elf, char *found_phdr, char *found_relro,
shown = 0;
multi_stack = multi_relro = multi_load = 0;
+ max_pt_load = elf_max_pt_load(elf);
#define SHOW_PHDR(B) \
if (elf->elf_class == ELFCLASS ## B) { \
@@ -167,7 +168,7 @@ static char *scanelf_file_phdr(elfobj *elf, char *found_phdr, char *found_relro,
offset = 4; \
check_flags = PF_X; \
} else if (EGET(phdr[i].p_type) == PT_LOAD) { \
- if (multi_load++ > 2) warnf("%s: more than 2 PT_LOAD's !?", elf->filename); \
+ if (multi_load++ > max_pt_load) warnf("%s: more than %i PT_LOAD's !?", elf->filename, max_pt_load); \
found = found_load; \
offset = 8; \
check_flags = PF_W|PF_X; \