PhotoRec: avoid spliting .edb file when detecting the backup header

This commit is contained in:
Christophe Grenier 2013-03-23 14:48:21 +01:00
parent 1c24eb562c
commit ebb1f8e44d

View File

@ -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)
{
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);
}