summaryrefslogtreecommitdiffstats
path: root/src/file_frm.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-08-13 08:47:59 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2014-08-13 08:47:59 +0200
commit4016c069d598cc87316cd8f0f68510273d818df0 (patch)
treecd95e8207e565c0ec206697d66b1aeb9130147aa /src/file_frm.c
parentff30c107f64f21e7ec430ccad17bb64c10cc3ade (diff)
PhotoRec: stricter check for .frm
Diffstat (limited to 'src/file_frm.c')
-rw-r--r--src/file_frm.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/file_frm.c b/src/file_frm.c
index a861fd9..826bd8d 100644
--- a/src/file_frm.c
+++ b/src/file_frm.c
@@ -45,31 +45,28 @@ const file_hint_t file_hint_frm= {
.register_header_check=&register_header_check_frm
};
-static const unsigned char frm_header[14]= {
- '#', 'U', 'G', 'C', ':', '2', ' ', 'D',
- 'W', 'G', 'F', 'O', 'R', 'M'};
-
-static void register_header_check_frm(file_stat_t *file_stat)
+static void file_check_frm(file_recovery_t *file_recovery)
{
- register_header_check(0, frm_header,sizeof(frm_header), &header_check_frm, file_stat);
+ const unsigned char frm_footer[11]= {
+ '#', 'E', 'N', 'D', '_', 'O', 'F', '_',
+ 'U', 'G', 'C'};
+ file_search_footer(file_recovery, frm_footer, sizeof(frm_footer), 1);
}
static int header_check_frm(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,frm_header,sizeof(frm_header))==0)
- {
- reset_file_recovery(file_recovery_new);
- file_recovery_new->file_check=file_check_frm;
- file_recovery_new->extension=file_hint_frm.extension;
- return 1;
- }
- return 0;
+ if(!isprint(buffer[14]) || !isprint(buffer[15]) || !isprint(buffer[16]) || !isprint(buffer[17]))
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->file_check=file_check_frm;
+ file_recovery_new->extension=file_hint_frm.extension;
+ return 1;
}
-static void file_check_frm(file_recovery_t *file_recovery)
+static void register_header_check_frm(file_stat_t *file_stat)
{
- const unsigned char frm_footer[11]= {
- '#', 'E', 'N', 'D', '_', 'O', 'F', '_',
- 'U', 'G', 'C'};
- file_search_footer(file_recovery, frm_footer, sizeof(frm_footer), 1);
+ static const unsigned char frm_header[14]= {
+ '#', 'U', 'G', 'C', ':', '2', ' ', 'D',
+ 'W', 'G', 'F', 'O', 'R', 'M'};
+ register_header_check(0, frm_header,sizeof(frm_header), &header_check_frm, file_stat);
}