summaryrefslogtreecommitdiffstats
path: root/src/file_elf.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-03-10 15:58:57 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2013-03-10 15:58:57 +0100
commit358269b5aeb979a5b9e858f0dbdaf3c19ec00f19 (patch)
tree48d57338dbe30eb4ae68117acf04fdf7ef1438c2 /src/file_elf.c
parentb2d291cb0020b9b83a07509534a5b73acdb3ff37 (diff)
PhotoRec: better signatures for ELF
Diffstat (limited to 'src/file_elf.c')
-rw-r--r--src/file_elf.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/file_elf.c b/src/file_elf.c
index 10e10bc..b48db4b 100644
--- a/src/file_elf.c
+++ b/src/file_elf.c
@@ -32,7 +32,6 @@
#include "filegen.h"
static void register_header_check_elf(file_stat_t *file_stat);
-static int header_check_elf(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new);
const file_hint_t file_hint_elf= {
.extension="elf",
@@ -44,20 +43,17 @@ const file_hint_t file_hint_elf= {
.register_header_check=&register_header_check_elf
};
-static const unsigned char elf_header[4] = { 0x7f, 'E','L','F'};
-
-static void register_header_check_elf(file_stat_t *file_stat)
+static int header_check_elf(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
{
- register_header_check(0, elf_header,sizeof(elf_header), &header_check_elf, file_stat);
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_elf.extension;
+ return 1;
}
-static int header_check_elf(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
+static void register_header_check_elf(file_stat_t *file_stat)
{
- if(memcmp(buffer,elf_header,sizeof(elf_header))==0)
- {
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_elf.extension;
- return 1;
- }
- return 0;
+ static const unsigned char elf_header16[4] = { 0x7f, 'E','L','F',0x01};
+ static const unsigned char elf_header32[4] = { 0x7f, 'E','L','F',0x02};
+ register_header_check(0, elf_header16, sizeof(elf_header16), &header_check_elf, file_stat);
+ register_header_check(0, elf_header32, sizeof(elf_header32), &header_check_elf, file_stat);
}