summaryrefslogtreecommitdiffstats
path: root/src/file_myo.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-07-26 18:45:32 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2014-07-26 18:45:32 +0200
commit4617f139ba19b9f0d6ff040c591f6e21b13c0a94 (patch)
tree98ec43c3f2cba2afea30f929a3d4223039d5ae03 /src/file_myo.c
parentba0400f352d757572ff69b8af644ed1d5a75ea32 (diff)
PhotoRec: stricter check for .myo
Diffstat (limited to 'src/file_myo.c')
-rw-r--r--src/file_myo.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/file_myo.c b/src/file_myo.c
index 1043a53..f78f206 100644
--- a/src/file_myo.c
+++ b/src/file_myo.c
@@ -43,25 +43,22 @@ const file_hint_t file_hint_myo= {
.register_header_check=&register_header_check_myo
};
-static const unsigned char myo_header[6]= {
- 'F', 'C', '!', 'D', 'E', 'F'
-};
-static void register_header_check_myo(file_stat_t *file_stat)
+static int header_check_myo(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)
{
- register_header_check(0x9ce, myo_header, sizeof(myo_header), &header_check_myo, file_stat);
+ const uint64_t size=(uint64_t)buffer[0]+(((uint64_t)buffer[1])<<8)+(((uint64_t)buffer[2])<<16)+(((uint64_t)buffer[3])<<24)+1;
+ if(size < 0x9ce + 6)
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_myo.extension;
+ file_recovery_new->calculated_file_size=size;
+ file_recovery_new->data_check=&data_check_size;
+ file_recovery_new->file_check=&file_check_size;
+ return 1;
}
-static int header_check_myo(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)
+
+static void register_header_check_myo(file_stat_t *file_stat)
{
- if(memcmp(&buffer[0x9ce], myo_header, sizeof(myo_header))==0)
- {
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_myo.extension;
- file_recovery_new->calculated_file_size=(uint64_t)buffer[0]+(((uint64_t)buffer[1])<<8)+(((uint64_t)buffer[2])<<16)+(((uint64_t)buffer[3])<<24)+1;
- file_recovery_new->data_check=&data_check_size;
- file_recovery_new->file_check=&file_check_size;
- return 1;
- }
- return 0;
+ register_header_check(0x9ce, "FC!DEF", 6, &header_check_myo, file_stat);
}