summaryrefslogtreecommitdiffstats
path: root/src/file_chm.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-07-21 21:04:26 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2014-07-21 21:04:26 +0200
commitc3e0bcc637a9356ef7f61c47cbaf2efd6d2eab32 (patch)
treef17ed8e1883ba3490672245d94becaee2e84545f /src/file_chm.c
parent840b9f74e2eecb2a608c8020cb30bb802c00e9b8 (diff)
PhotoRec: stricter check for .chm
Diffstat (limited to 'src/file_chm.c')
-rw-r--r--src/file_chm.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/file_chm.c b/src/file_chm.c
index b7af3e4..e705691 100644
--- a/src/file_chm.c
+++ b/src/file_chm.c
@@ -44,8 +44,11 @@ const file_hint_t file_hint_chm= {
static int header_check_chm(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=(buffer[104]<<0)+(buffer[105]<<8)+(buffer[106]<<16)+((uint64_t)buffer[107]<<24);
+ if(size < 108)
+ return 0;
reset_file_recovery(file_recovery_new);
- file_recovery_new->calculated_file_size=(buffer[104]<<0)+(buffer[105]<<8)+(buffer[106]<<16)+((uint64_t)buffer[107]<<24);
+ file_recovery_new->calculated_file_size=size;
file_recovery_new->data_check=&data_check_size;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->extension=file_hint_chm.extension;