summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-07-26 22:51:32 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2014-07-26 22:51:32 +0200
commit0b47724ef582ae21cec8ca5e0047e00bb9a986fe (patch)
tree7ede74fc85ed1cec5edc504bf7ab0128d709011f
parent1ef60b15f9a2b1d4d14d219c856d39affc9dff67 (diff)
PhotoRec: stricter check for .wdp
-rw-r--r--src/file_wdp.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/file_wdp.c b/src/file_wdp.c
index 72c7728..0ab5e92 100644
--- a/src/file_wdp.c
+++ b/src/file_wdp.c
@@ -30,6 +30,7 @@
#include "types.h"
#include "filegen.h"
#include "file_tiff.h"
+#include "common.h"
static void register_header_check_wdp(file_stat_t *file_stat);
static int header_check_wdp(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);
@@ -44,24 +45,20 @@ const file_hint_t file_hint_wdp= {
.register_header_check=&register_header_check_wdp
};
-static const unsigned char wdp_header[4]= {'I', 'I', 0xbc, 0x01};
-
-static void register_header_check_wdp(file_stat_t *file_stat)
+static int header_check_wdp(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(0, wdp_header, sizeof(wdp_header), &header_check_wdp, file_stat);
+ const TIFFHeader *header=(const TIFFHeader *)buffer;
+ if(le32(header->tiff_diroff) < sizeof(TIFFHeader))
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension="wdp";
+ file_recovery_new->time=get_date_from_tiff_header((const TIFFHeader *)buffer, buffer_size);
+ file_recovery_new->file_check=&file_check_tiff;
+ return 1;
}
-static int header_check_wdp(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_wdp(file_stat_t *file_stat)
{
- if(memcmp(buffer, wdp_header, sizeof(wdp_header))==0)
- {
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension="wdp";
- file_recovery_new->time=get_date_from_tiff_header((const TIFFHeader *)buffer, buffer_size);
- file_recovery_new->file_check=&file_check_tiff;
- return 1;
- }
- return 0;
+ static const unsigned char wdp_header[4]= {'I', 'I', 0xbc, 0x01};
+ register_header_check(0, wdp_header, sizeof(wdp_header), &header_check_wdp, file_stat);
}
-
-