summaryrefslogtreecommitdiffstats
path: root/src/file_xv.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-08-13 08:48:34 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2014-08-13 08:48:34 +0200
commitd05ac1304b9d42d169b6af2f65e7cae997ad218b (patch)
tree6090ebd10c274f41b1954d71345e58da6361a4d8 /src/file_xv.c
parent46fdea108cd682100b357f93f653e6d77d5a39d6 (diff)
PhotoRec: stricter check for .xv
Diffstat (limited to 'src/file_xv.c')
-rw-r--r--src/file_xv.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/file_xv.c b/src/file_xv.c
index 236a60d..9722110 100644
--- a/src/file_xv.c
+++ b/src/file_xv.c
@@ -44,20 +44,18 @@ const file_hint_t file_hint_xv= {
.register_header_check=&register_header_check_xv
};
-static const unsigned char xv_header[7]= {'P', '7', ' ', '3', '3', '2', '\n'};
+static int header_check_xv(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(!isprint(buffer[7]) || !isprint(buffer[8]) || !isprint(buffer[9]))
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_xv.extension;
+ return 1;
+}
static void register_header_check_xv(file_stat_t *file_stat)
{
+ static const unsigned char xv_header[7]= {'P', '7', ' ', '3', '3', '2', '\n'};
register_header_check(0, xv_header, sizeof(xv_header), &header_check_xv, file_stat);
}
-static int header_check_xv(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,xv_header,sizeof(xv_header))==0)
- {
- reset_file_recovery(file_recovery_new);
- file_recovery_new->extension=file_hint_xv.extension;
- return 1;
- }
- return 0;
-}