summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2020-09-13 16:24:01 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2020-09-13 16:24:01 +0200
commit1e240053d7f59f9faa26f34d083bfd4b0ec1bc6c (patch)
treedf43636627f8f64bb10cf97defe5cf8e1d0f5f89
parentb478a161acc8cb39c10c7cf9040a49b8d86c2b64 (diff)
PhotoRec: discard fm header when the recorded size is too large for a
real file
-rw-r--r--src/file_fm.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/file_fm.c b/src/file_fm.c
index 12479d2..d5800c2 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;