summaryrefslogtreecommitdiffstats
path: root/src/file_par2.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-08-13 08:33:14 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2014-08-13 08:33:14 +0200
commit69e5dde9c0112a6b9c325a44a3fc11d2f8cc9ea6 (patch)
tree8e96d2843ff03a21a8836bd1b1a06331789948f0 /src/file_par2.c
parent736adffc5038db051d291650abc6e0782bb960bd (diff)
PhotoRec: stricter check for .par2
Diffstat (limited to 'src/file_par2.c')
-rw-r--r--src/file_par2.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/file_par2.c b/src/file_par2.c
index d2a765f..20bc459 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;