summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-05-26 22:16:54 +0100
committernorly <ny-git@enpas.org>2013-05-27 03:10:31 +0100
commitf5eac562c915811c27969949c178f8fe96a12e47 (patch)
tree7713d3c13719825ed96210f2acc4c34d796597b8 /include
parent3d899fbfd33a8b44dcbd7dfbc952464731a7e589 (diff)
Validate input at libelf level
This way we can just assume that stuff works later on and keep the code clean and simple. It especially establishes that the file has a sane format and is thus understandable and editable.
Diffstat (limited to 'include')
-rw-r--r--include/libelfu/elfops.h2
-rw-r--r--include/libelfu/generic.h15
2 files changed, 16 insertions, 1 deletions
diff --git a/include/libelfu/elfops.h b/include/libelfu/elfops.h
index 58da4cf..cf40090 100644
--- a/include/libelfu/elfops.h
+++ b/include/libelfu/elfops.h
@@ -7,6 +7,8 @@
#include <libelfu/types.h>
+int elfu_eCheck(Elf *e);
+
char* elfu_eScnName(Elf *e, Elf_Scn *scn);
Elf_Scn* elfu_eScnByName(Elf *e, char *name);
diff --git a/include/libelfu/generic.h b/include/libelfu/generic.h
index f5b0e0f..09d2ffc 100644
--- a/include/libelfu/generic.h
+++ b/include/libelfu/generic.h
@@ -3,9 +3,22 @@
#include <libelf/gelf.h>
+#define OFFS_END(off, sz) ((off) + (sz))
+
+#define OVERLAPPING(off1, sz1, off2, sz2) \
+ (!((off1) == (off2) && ((sz1 == 0) || (sz2 == 0))) \
+ && (((off1) <= (off2) && (off2) < OFFS_END((off1), (sz1))) \
+ || ((off2) <= (off1) && (off1) < OFFS_END((off2), (sz2)))) \
+ )
+
+#define FULLY_OVERLAPPING(off1, sz1, off2, sz2) \
+ (((off1) <= (off2) && OFFS_END((off2), (sz2)) <= OFFS_END((off1), (sz1))) \
+ || ((off2) <= (off1) && OFFS_END((off1), (sz1)) <= OFFS_END((off2), (sz2))))
+
-size_t elfu_gScnSizeFile(const GElf_Shdr *shdr);
int elfu_gPhdrContainsScn(GElf_Phdr *phdr, GElf_Shdr *shdr);
+size_t elfu_gScnSizeFile(const GElf_Shdr *shdr);
+
#endif