From 1e240053d7f59f9faa26f34d083bfd4b0ec1bc6c Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Sun, 13 Sep 2020 16:24:01 +0200 Subject: [PATCH] PhotoRec: discard fm header when the recorded size is too large for a real file --- src/file_fm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/file_fm.c b/src/file_fm.c index 12479d20..d5800c2e 100644 --- a/src/file_fm.c +++ b/src/file_fm.c @@ -52,6 +52,8 @@ struct fm_header static int header_check_fm(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 struct fm_header *hdr=(const struct fm_header *)buffer; + if(le64(hdr->size) > PHOTOREC_MAX_FILE_SIZE) + return 0; reset_file_recovery(file_recovery_new); file_recovery_new->extension=file_hint_fm.extension; file_recovery_new->calculated_file_size=(uint64_t)le64(hdr->size) + 12833;