summaryrefslogtreecommitdiffstats
path: root/src/file_edb.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-03-23 14:48:21 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2013-03-23 14:48:21 +0100
commitebb1f8e44d0220aa999d1bf30a66c06a0aad26cb (patch)
tree3776c320413be43de1dff4790f14166936671a2a /src/file_edb.c
parent1c24eb562c99321f98280dc937a9affb4de7f025 (diff)
PhotoRec: avoid spliting .edb file when detecting the backup header
Diffstat (limited to 'src/file_edb.c')
-rw-r--r--src/file_edb.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/file_edb.c b/src/file_edb.c
index 1db9f5a..920e324 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=&register_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)
+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)
{
- register_header_check(4, edb_magic, sizeof(edb_magic), &header_check_edb, file_stat);
+ /* 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 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)
+static void register_header_check_edb(file_stat_t *file_stat)
{
- 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;
+ 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);
}