From ebb1f8e44d0220aa999d1bf30a66c06a0aad26cb Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Sat, 23 Mar 2013 14:48:21 +0100 Subject: [PATCH] PhotoRec: avoid spliting .edb file when detecting the backup header --- src/file_edb.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/file_edb.c b/src/file_edb.c index 1db9f5aa..920e3248 100644 --- a/src/file_edb.c +++ b/src/file_edb.c @@ -35,7 +35,6 @@ #include "filegen.h" static void register_header_check_edb(file_stat_t *file_stat); -static int header_check_edb(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_edb= { .extension="edb", @@ -47,22 +46,23 @@ const file_hint_t file_hint_edb= { .register_header_check=®ister_header_check_edb }; -static const unsigned char edb_magic[8]= { - 0xef, 0xcd, 0xab, 0x89, 0x20, 0x06, 0x00, 0x00 -}; - -static void register_header_check_edb(file_stat_t *file_stat) -{ - register_header_check(4, edb_magic, sizeof(edb_magic), &header_check_edb, file_stat); -} static int header_check_edb(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) { - if(memcmp(&buffer[4], edb_magic, sizeof(edb_magic))==0) - { - reset_file_recovery(file_recovery_new); - file_recovery_new->extension=file_hint_edb.extension; - return 1; - } - return 0; + /* A backup of the header is stored in the second block */ + if(file_recovery!=NULL && file_recovery->file_stat!=NULL && + file_recovery->file_stat->file_hint==&file_hint_edb && + file_recovery->file_size==4096) + return 0; + reset_file_recovery(file_recovery_new); + file_recovery_new->extension=file_hint_edb.extension; + return 1; +} + +static void register_header_check_edb(file_stat_t *file_stat) +{ + static const unsigned char edb_magic[8]= { + 0xef, 0xcd, 0xab, 0x89, 0x20, 0x06, 0x00, 0x00 + }; + register_header_check(4, edb_magic, sizeof(edb_magic), &header_check_edb, file_stat); }