From 69e5dde9c0112a6b9c325a44a3fc11d2f8cc9ea6 Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Wed, 13 Aug 2014 08:33:14 +0200 Subject: [PATCH] PhotoRec: stricter check for .par2 --- src/file_par2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/file_par2.c b/src/file_par2.c index d2a765f4..20bc459f 100644 --- a/src/file_par2.c +++ b/src/file_par2.c @@ -108,10 +108,13 @@ static void file_rename_par2(const char *old_filename) static int header_check_par2(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 length=le64((*(const uint64_t *)(&buffer[8]))); if(file_recovery!=NULL && file_recovery->file_stat!=NULL && file_recovery->file_stat->file_hint==&file_hint_par2) return 0; + if(length % 4 !=0 || length < 16) + return 0; reset_file_recovery(file_recovery_new); file_recovery_new->extension=file_hint_par2.extension; file_recovery_new->file_rename=&file_rename_par2;