PhotoRec: stricter check for .tph

This commit is contained in:
Christophe Grenier 2014-08-13 08:48:11 +02:00
parent 4016c069d5
commit 46fdea108c

View file

@ -45,28 +45,6 @@ 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)
{
register_header_check(0, tph_header,sizeof(tph_header), &header_check_tph, file_stat);
}
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;
}
static void file_check_tph(file_recovery_t *file_recovery)
{
const unsigned char tph_footer[11]= {
@ -74,3 +52,22 @@ static void file_check_tph(file_recovery_t *file_recovery)
'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(!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 register_header_check_tph(file_stat_t *file_stat)
{
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);
}