PhotoRec: src/file_gz.c, src/file_mp3.c: header_ignored_adv() must be called only
once all checks have been done.
This commit is contained in:
parent
351babdc43
commit
9f4bb675a6
2 changed files with 59 additions and 50 deletions
|
@ -157,18 +157,7 @@ static int header_check_gz(const unsigned char *buffer, const unsigned int buffe
|
||||||
}
|
}
|
||||||
if(off >= 512 || off >= buffer_size)
|
if(off >= 512 || off >= buffer_size)
|
||||||
return 0;
|
return 0;
|
||||||
if(file_recovery->file_stat!=NULL &&
|
#if defined(HAVE_ZLIB_H) && defined(HAVE_LIBZ) && !defined(__FRAMAC__)
|
||||||
file_recovery->file_stat->file_hint==&file_hint_doc)
|
|
||||||
{
|
|
||||||
if(header_ignored_adv(file_recovery, file_recovery_new)==0)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if(file_recovery->file_check==&file_check_bgzf)
|
|
||||||
{
|
|
||||||
header_ignored(file_recovery_new);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#if defined(HAVE_ZLIB_H) && defined(HAVE_LIBZ)
|
|
||||||
{
|
{
|
||||||
static const unsigned char schematic_header[12]={ 0x0a, 0x00, 0x09,
|
static const unsigned char schematic_header[12]={ 0x0a, 0x00, 0x09,
|
||||||
'S', 'c', 'h', 'e', 'm', 'a', 't', 'i', 'c'};
|
'S', 'c', 'h', 'e', 'm', 'a', 't', 'i', 'c'};
|
||||||
|
@ -207,6 +196,17 @@ static int header_check_gz(const unsigned char *buffer, const unsigned int buffe
|
||||||
/* Probably too small to be a file */
|
/* Probably too small to be a file */
|
||||||
if(d_stream.total_out < 16)
|
if(d_stream.total_out < 16)
|
||||||
return 0;
|
return 0;
|
||||||
|
if(file_recovery->file_stat!=NULL &&
|
||||||
|
file_recovery->file_stat->file_hint==&file_hint_doc)
|
||||||
|
{
|
||||||
|
if(header_ignored_adv(file_recovery, file_recovery_new)==0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(file_recovery->file_check==&file_check_bgzf)
|
||||||
|
{
|
||||||
|
header_ignored(file_recovery_new);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
buffer_uncompr[d_stream.total_out]='\0';
|
buffer_uncompr[d_stream.total_out]='\0';
|
||||||
if(bgzf!=0)
|
if(bgzf!=0)
|
||||||
{
|
{
|
||||||
|
@ -297,6 +297,17 @@ static int header_check_gz(const unsigned char *buffer, const unsigned int buffe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
if(file_recovery->file_stat!=NULL &&
|
||||||
|
file_recovery->file_stat->file_hint==&file_hint_doc)
|
||||||
|
{
|
||||||
|
if(header_ignored_adv(file_recovery, file_recovery_new)==0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(file_recovery->file_check==&file_check_bgzf)
|
||||||
|
{
|
||||||
|
header_ignored(file_recovery_new);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
reset_file_recovery(file_recovery_new);
|
reset_file_recovery(file_recovery_new);
|
||||||
file_recovery_new->min_filesize=22;
|
file_recovery_new->min_filesize=22;
|
||||||
file_recovery_new->time=le32(gz->mtime);
|
file_recovery_new->time=le32(gz->mtime);
|
||||||
|
|
|
@ -534,27 +534,6 @@ static int header_check_mp3(const unsigned char *buffer, const unsigned int buff
|
||||||
(buffer[1]&0xFE)==0xF2 ||
|
(buffer[1]&0xFE)==0xF2 ||
|
||||||
(buffer[1]&0xFE)==0xE2)))
|
(buffer[1]&0xFE)==0xE2)))
|
||||||
return 0;
|
return 0;
|
||||||
if(file_recovery->file_stat!=NULL)
|
|
||||||
{
|
|
||||||
if(file_recovery->file_stat->file_hint==&file_hint_mp3
|
|
||||||
#if !defined(MAIN_mp3)
|
|
||||||
|| file_recovery->file_stat->file_hint==&file_hint_mkv
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
|
||||||
header_ignored(file_recovery_new);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#if !defined(MAIN_mp3)
|
|
||||||
/* RGV values from TIFF may be similar to the beginning of an mp3 */
|
|
||||||
if(file_recovery->file_stat->file_hint==&file_hint_tiff &&
|
|
||||||
buffer[0]==buffer[3] && buffer[1]==buffer[4] && buffer[2]==buffer[5])
|
|
||||||
{
|
|
||||||
if(header_ignored_adv(file_recovery, file_recovery_new)==0)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/*@ assert nbr == 0; */
|
/*@ assert nbr == 0; */
|
||||||
/*@
|
/*@
|
||||||
@ loop invariant 0 <= nbr <= potential_frame_offset <= 2048 + 8065;
|
@ loop invariant 0 <= nbr <= potential_frame_offset <= 2048 + 8065;
|
||||||
|
@ -603,8 +582,29 @@ static int header_check_mp3(const unsigned char *buffer, const unsigned int buff
|
||||||
nbr++;
|
nbr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(nbr>1)
|
if(nbr<=1)
|
||||||
|
return 0;
|
||||||
|
if(file_recovery->file_stat!=NULL)
|
||||||
{
|
{
|
||||||
|
if(file_recovery->file_stat->file_hint==&file_hint_mp3
|
||||||
|
#if !defined(MAIN_mp3)
|
||||||
|
|| file_recovery->file_stat->file_hint==&file_hint_mkv
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
header_ignored(file_recovery_new);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#if !defined(MAIN_mp3)
|
||||||
|
/* RGV values from TIFF may be similar to the beginning of an mp3 */
|
||||||
|
if(file_recovery->file_stat->file_hint==&file_hint_tiff &&
|
||||||
|
buffer[0]==buffer[3] && buffer[1]==buffer[4] && buffer[2]==buffer[5])
|
||||||
|
{
|
||||||
|
if(header_ignored_adv(file_recovery, file_recovery_new)==0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
/*@ assert nbr > 1; */
|
/*@ assert nbr > 1; */
|
||||||
/*@ assert potential_frame_offset > 0; */
|
/*@ assert potential_frame_offset > 0; */
|
||||||
#ifdef DEBUG_MP3
|
#ifdef DEBUG_MP3
|
||||||
|
@ -624,8 +624,6 @@ static int header_check_mp3(const unsigned char *buffer, const unsigned int buff
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
@ requires \valid(file_stat);
|
@ requires \valid(file_stat);
|
||||||
|
|
Loading…
Reference in a new issue