summaryrefslogtreecommitdiffstats
path: root/src/file_dmp.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-08-09 09:43:32 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2014-08-09 09:43:32 +0200
commit3e3745fb7fcabd79d8950b90801327309d079b50 (patch)
tree9938abec7471d8047b8a6724538f1ed81f7e8002 /src/file_dmp.c
parenta322b3f823324677213459d278ca94e6677dd681 (diff)
PhotoRec: stricter check for .dmp
Diffstat (limited to 'src/file_dmp.c')
-rw-r--r--src/file_dmp.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/file_dmp.c b/src/file_dmp.c
index 01cfd9c..0532e9c 100644
--- a/src/file_dmp.c
+++ b/src/file_dmp.c
@@ -31,7 +31,6 @@
#include "filegen.h"
static void register_header_check_dmp(file_stat_t *file_stat);
-static int header_check_dmp(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 file_hint_t file_hint_dmp= {
.extension="dmp",
@@ -43,23 +42,21 @@ const file_hint_t file_hint_dmp= {
.register_header_check=&register_header_check_dmp
};
-static const unsigned char dmp_header[11]= {
- 0x03, 0x00, 0x01, 'E', 'X', 'P', 'O', 'R',
- 'T', ':', 'V'
-};
+static int header_check_dmp(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)
+{
+ if(buffer[11] < '0' || buffer[11] > '9')
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_dmp.extension;
+ return 1;
+}
static void register_header_check_dmp(file_stat_t *file_stat)
{
+ static const unsigned char dmp_header[11]= {
+ 0x03, 0x00, 0x01, 'E', 'X', 'P', 'O', 'R',
+ 'T', ':', 'V'
+ };
register_header_check(0, dmp_header, sizeof(dmp_header), &header_check_dmp, file_stat);
}
-static int header_check_dmp(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)
-{
- if(memcmp(&buffer[0], dmp_header, sizeof(dmp_header))==0)
- {
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_dmp.extension;
- return 1;
- }
- return 0;
-}