From e911b57a113499c0919583f3d070be9d6a5bf636 Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Thu, 24 Jul 2014 23:41:45 +0200 Subject: [PATCH] PhotoRec: stricter check for .dat --- src/file_dat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/file_dat.c b/src/file_dat.c index f291494e..3737013b 100644 --- a/src/file_dat.c +++ b/src/file_dat.c @@ -51,10 +51,13 @@ static int header_check_dat(const unsigned char *buffer, const unsigned int buff static int header_check_datIE(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 uint64_t size=(uint64_t)buffer[0x1C]+(((uint64_t)buffer[0x1D])<<8)+(((uint64_t)buffer[0x1E])<<16)+(((uint64_t)buffer[0x1F])<<24); + if(size < 0x20) + return 0; reset_file_recovery(file_recovery_new); file_recovery_new->extension=file_hint_dat.extension; file_recovery_new->min_filesize=0x20; - file_recovery_new->calculated_file_size=(uint64_t)buffer[0x1C]+(((uint64_t)buffer[0x1D])<<8)+(((uint64_t)buffer[0x1E])<<16)+(((uint64_t)buffer[0x1F])<<24); + file_recovery_new->calculated_file_size=size; file_recovery_new->data_check=&data_check_size; file_recovery_new->file_check=&file_check_size; return 1;