summaryrefslogtreecommitdiffstats
path: root/src/file_wtv.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2015-05-11 09:25:39 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2015-05-11 09:25:39 +0200
commite1ca4010307fb53d83c5036f6c8269eb9066c928 (patch)
tree79a9547954c70be7ddc88324990d60a163ffb16d /src/file_wtv.c
parentf63304053aa32515e4853c2472fb785bcda0307c (diff)
remove always-true memcmp
Diffstat (limited to 'src/file_wtv.c')
-rw-r--r--src/file_wtv.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/file_wtv.c b/src/file_wtv.c
index fe4fbcb..669b6d9 100644
--- a/src/file_wtv.c
+++ b/src/file_wtv.c
@@ -44,33 +44,29 @@ const file_hint_t file_hint_wtv= {
.register_header_check=&register_header_check_wtv
};
-static const unsigned char wtv_header[16]= {
- 0xb7, 0xd8, 0x00, ' ' , '7' , 'I' , 0xda, 0x11,
- 0xa6, 'N' , 0x00, 0x07, 0xe9, 0x5e, 0xad, 0x8d
-};
-
-static void register_header_check_wtv(file_stat_t *file_stat)
-{
- register_header_check(0, wtv_header, sizeof(wtv_header), &header_check_wtv, file_stat);
-}
static int header_check_wtv(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 uint32_t *size=(const uint32_t *)(&buffer[0x5c]);
+ if(le32(*size)==0)
+ return 0;
if(file_recovery->file_stat!=NULL &&
file_recovery->file_stat->file_hint==&file_hint_wtv &&
file_recovery->file_size<=0x3000)
return 0;
- if(memcmp(&buffer[0], wtv_header, sizeof(wtv_header))==0)
- {
- const uint32_t *size=(const uint32_t *)(&buffer[0x5c]);
- if(le32(*size)==0)
- return 0;
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_wtv.extension;
- file_recovery_new->calculated_file_size=((uint64_t)le32(*size))<<12;
- file_recovery_new->data_check=&data_check_size;
- file_recovery_new->file_check=&file_check_size;
- return 1;
- }
- return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_wtv.extension;
+ file_recovery_new->calculated_file_size=((uint64_t)le32(*size))<<12;
+ file_recovery_new->data_check=&data_check_size;
+ file_recovery_new->file_check=&file_check_size;
+ return 1;
+}
+
+static void register_header_check_wtv(file_stat_t *file_stat)
+{
+ static const unsigned char wtv_header[16]= {
+ 0xb7, 0xd8, 0x00, ' ' , '7' , 'I' , 0xda, 0x11,
+ 0xa6, 'N' , 0x00, 0x07, 0xe9, 0x5e, 0xad, 0x8d
+ };
+ register_header_check(0, wtv_header, sizeof(wtv_header), &header_check_wtv, file_stat);
}