summaryrefslogtreecommitdiffstats
path: root/src/file_wv.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-07-26 22:54:18 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2014-07-26 22:54:18 +0200
commit7862b761c6495bb8dca25c23edb310507626a307 (patch)
treefcacfd98ffadd8e0fa35db65baa2b921a4f8e0b3 /src/file_wv.c
parent9169485c813c36d566105f4c290b8071f48eb5f0 (diff)
PhotoRec: stricter check for .wv
Diffstat (limited to 'src/file_wv.c')
-rw-r--r--src/file_wv.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/file_wv.c b/src/file_wv.c
index cfaacbe..0fe7220 100644
--- a/src/file_wv.c
+++ b/src/file_wv.c
@@ -32,7 +32,6 @@
#include "common.h"
static void register_header_check_wv(file_stat_t *file_stat);
-static int header_check_wv(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 data_check_t data_check_wv(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery);
const file_hint_t file_hint_wv= {
@@ -65,22 +64,17 @@ typedef struct {
uint32_t crc; // crc for actual decoded data
} WavpackHeader;
-static void register_header_check_wv(file_stat_t *file_stat)
-{
- register_header_check(0, wv_header, sizeof(wv_header), &header_check_wv, file_stat);
-}
-
static int header_check_wv(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 WavpackHeader *wv=(const WavpackHeader*)buffer;
- if(memcmp(buffer, wv_header, sizeof(wv_header))==0 && le32(wv->block_index)==0)
- {
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_wv.extension;
- file_recovery_new->data_check=&data_check_wv;
+ if(le32(wv->block_index)!=0)
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_wv.extension;
+ if(file_recovery_new->blocksize < 8)
return 1;
- }
- return 0;
+ file_recovery_new->data_check=&data_check_wv;
+ return 1;
}
static data_check_t data_check_wv(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery)
@@ -115,3 +109,7 @@ static data_check_t data_check_wv(const unsigned char *buffer, const unsigned in
return DC_CONTINUE;
}
+static void register_header_check_wv(file_stat_t *file_stat)
+{
+ register_header_check(0, wv_header, sizeof(wv_header), &header_check_wv, file_stat);
+}