summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-08-13 08:48:11 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2014-08-13 08:48:11 +0200
commit46fdea108cd682100b357f93f653e6d77d5a39d6 (patch)
treee8341c90122642475d10ad19e0243397957f3189
parent4016c069d598cc87316cd8f0f68510273d818df0 (diff)
PhotoRec: stricter check for .tph
-rw-r--r--src/file_tph.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/file_tph.c b/src/file_tph.c
index 243f52b..4aa7de7 100644
--- a/src/file_tph.c
+++ b/src/file_tph.c
@@ -45,32 +45,29 @@ const file_hint_t file_hint_tph= {
.register_header_check=&register_header_check_tph
};
-static const unsigned char tph_header[20]= {
- '#', 'U', 'G', 'C', ':', '2', ' ', 'M',
- 'F', 'G', '_', 'T', 'O', 'O', 'L', '_',
- 'P', 'A', 'T', 'H'};
-
-static void register_header_check_tph(file_stat_t *file_stat)
+static void file_check_tph(file_recovery_t *file_recovery)
{
- register_header_check(0, tph_header,sizeof(tph_header), &header_check_tph, file_stat);
+ const unsigned char tph_footer[11]= {
+ '#', 'E', 'N', 'D', '_', 'O', 'F', '_',
+ 'U', 'G', 'C'};
+ file_search_footer(file_recovery, tph_footer, sizeof(tph_footer), 1);
}
static int header_check_tph(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,tph_header,sizeof(tph_header))==0)
- {
- reset_file_recovery(file_recovery_new);
- file_recovery_new->file_check=file_check_tph;
- file_recovery_new->extension=file_hint_tph.extension;
- return 1;
- }
- return 0;
+ if(!isprint(buffer[20]) || !isprint(buffer[21]) || !isprint(buffer[22]) || !isprint(buffer[23]))
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->file_check=file_check_tph;
+ file_recovery_new->extension=file_hint_tph.extension;
+ return 1;
}
-static void file_check_tph(file_recovery_t *file_recovery)
+static void register_header_check_tph(file_stat_t *file_stat)
{
- const unsigned char tph_footer[11]= {
- '#', 'E', 'N', 'D', '_', 'O', 'F', '_',
- 'U', 'G', 'C'};
- file_search_footer(file_recovery, tph_footer, sizeof(tph_footer), 1);
+ static const unsigned char tph_header[20]= {
+ '#', 'U', 'G', 'C', ':', '2', ' ', 'M',
+ 'F', 'G', '_', 'T', 'O', 'O', 'L', '_',
+ 'P', 'A', 'T', 'H'};
+ register_header_check(0, tph_header,sizeof(tph_header), &header_check_tph, file_stat);
}