PhotoRec: stricter check for .frm
This commit is contained in:
parent
ff30c107f6
commit
4016c069d5
1 changed files with 18 additions and 21 deletions
|
@ -45,27 +45,6 @@ const file_hint_t file_hint_frm= {
|
|||
.register_header_check=®ister_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)
|
||||
{
|
||||
register_header_check(0, frm_header,sizeof(frm_header), &header_check_frm, file_stat);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static void file_check_frm(file_recovery_t *file_recovery)
|
||||
{
|
||||
const unsigned char frm_footer[11]= {
|
||||
|
@ -73,3 +52,21 @@ static void file_check_frm(file_recovery_t *file_recovery)
|
|||
'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(!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 register_header_check_frm(file_stat_t *file_stat)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue