PhotoRec: stricter check for .asf detection
This commit is contained in:
parent
7129c28c12
commit
0f70bee69a
1 changed files with 36 additions and 45 deletions
|
@ -44,13 +44,6 @@ const file_hint_t file_hint_asf= {
|
|||
.register_header_check=®ister_header_check_asf
|
||||
};
|
||||
|
||||
static const unsigned char asf_header[4]= { 0x30,0x26,0xB2,0x75};
|
||||
|
||||
static void register_header_check_asf(file_stat_t *file_stat)
|
||||
{
|
||||
register_header_check(0, asf_header,sizeof(asf_header), &header_check_asf, file_stat);
|
||||
}
|
||||
|
||||
struct asf_header_obj_s {
|
||||
unsigned char object_id[16];
|
||||
uint64_t object_size;
|
||||
|
@ -69,15 +62,12 @@ struct asf_file_prop_s {
|
|||
|
||||
static int header_check_asf(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)
|
||||
{
|
||||
static const unsigned char asf_header_id[16]= {
|
||||
0x30, 0x26, 0xb2, 0x75, 0x8e, 0x66, 0xcf, 0x11,
|
||||
0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
|
||||
};
|
||||
if(memcmp(buffer, asf_header_id, sizeof(asf_header_id))==0)
|
||||
{
|
||||
unsigned int i;
|
||||
const struct asf_header_obj_s *asf_header_obj=(const struct asf_header_obj_s *)buffer;
|
||||
const struct asf_file_prop_s *asf_file_prop=(const struct asf_file_prop_s*)(asf_header_obj+1);
|
||||
const struct asf_file_prop_s *asf_file_prop=(const struct asf_file_prop_s*)(buffer+le64(asf_header_obj->object_size));
|
||||
unsigned int i;
|
||||
if(le64(asf_header_obj->object_size)<30 ||
|
||||
le64(asf_header_obj->object_size)>buffer_size)
|
||||
return 0;
|
||||
reset_file_recovery(file_recovery_new);
|
||||
file_recovery_new->extension=file_hint_asf.extension;
|
||||
for(i=0;
|
||||
|
@ -102,12 +92,13 @@ static int header_check_asf(const unsigned char *buffer, const unsigned int buff
|
|||
asf_file_prop=(const struct asf_file_prop_s *)((const char *)asf_file_prop + le64(asf_file_prop->object_size));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if(memcmp(buffer, asf_header, sizeof(asf_header))==0)
|
||||
{
|
||||
reset_file_recovery(file_recovery_new);
|
||||
file_recovery_new->extension=file_hint_asf.extension;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void register_header_check_asf(file_stat_t *file_stat)
|
||||
{
|
||||
static const unsigned char asf_header[16]= {
|
||||
0x30, 0x26, 0xb2, 0x75, 0x8e, 0x66, 0xcf, 0x11,
|
||||
0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
|
||||
};
|
||||
register_header_check(0, asf_header,sizeof(asf_header), &header_check_asf, file_stat);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue