summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-03-30 19:31:33 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2014-03-30 19:31:33 +0200
commita23c1b5a884bd22aa0eb9d9889c2e3980126925e (patch)
treec1709f604541cc41c5722d4f7bb1026bd4b5bff6
parent45903de1b5a8125c86254e2f712bc4f2d3a9f462 (diff)
PhotoRec: better check to avoid to concat mp3 files
-rw-r--r--src/file_bac.c2
-rw-r--r--src/file_caf.c2
-rw-r--r--src/file_dv.c4
-rw-r--r--src/file_emf.c2
-rw-r--r--src/file_mov.c24
-rw-r--r--src/file_mp3.c6
-rw-r--r--src/file_oci.c2
-rw-r--r--src/file_riff.c8
-rw-r--r--src/file_tib.c2
9 files changed, 27 insertions, 25 deletions
diff --git a/src/file_bac.c b/src/file_bac.c
index deb0877..395eb07 100644
--- a/src/file_bac.c
+++ b/src/file_bac.c
@@ -80,7 +80,7 @@ static int header_check_bac(const unsigned char *buffer, const unsigned int buff
file_recovery_new->calculated_file_size=0;
if(file_recovery_new->blocksize >= 0x18/2)
{
- file_recovery_new->data_check=data_check_bac;
+ file_recovery_new->data_check=&data_check_bac;
file_recovery_new->file_check=&file_check_size;
}
return 1;
diff --git a/src/file_caf.c b/src/file_caf.c
index 4ac581f..c41d74f 100644
--- a/src/file_caf.c
+++ b/src/file_caf.c
@@ -106,7 +106,7 @@ static int header_check_caf(const unsigned char *buffer, const unsigned int buff
{
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_caf.extension;
- file_recovery_new->data_check=data_check_caf;
+ file_recovery_new->data_check=&data_check_caf;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->calculated_file_size=8;
return 1;
diff --git a/src/file_dv.c b/src/file_dv.c
index 4d92bc4..d3d3713 100644
--- a/src/file_dv.c
+++ b/src/file_dv.c
@@ -52,7 +52,7 @@ static void register_header_check_dv(file_stat_t *file_stat)
static int header_check_dv(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(file_recovery!=NULL && file_recovery->file_stat!=NULL && file_recovery->file_stat->file_hint==&file_hint_dv)
+ if(file_recovery!=NULL && file_recovery->data_check==&data_check_dv)
return 0;
/* The header may be only 3 bytes */
if(buffer[0]==0x1f && buffer[1]==0x07 && buffer[2]==0x00 && buffer[5]==0x78 && buffer[6]==0x78 && buffer[7]==0x78)
@@ -60,7 +60,7 @@ static int header_check_dv(const unsigned char *buffer, const unsigned int buffe
/* NTSC */
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_dv.extension;
- file_recovery_new->data_check=data_check_dv;
+ file_recovery_new->data_check=&data_check_dv;
file_recovery_new->file_check=&file_check_size;
return 1;
}
diff --git a/src/file_emf.c b/src/file_emf.c
index 7f18652..bd6f068 100644
--- a/src/file_emf.c
+++ b/src/file_emf.c
@@ -222,7 +222,7 @@ static int header_check_emf(const unsigned char *buffer, const unsigned int buff
const unsigned int atom_size=buffer[4]+(buffer[5]<<8)+(buffer[6]<<16)+(buffer[7]<<24);
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_emf.extension;
- file_recovery_new->data_check=data_check_emf;
+ file_recovery_new->data_check=&data_check_emf;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->calculated_file_size=atom_size;
return 1;
diff --git a/src/file_mov.c b/src/file_mov.c
index b35112c..d7390b1 100644
--- a/src/file_mov.c
+++ b/src/file_mov.c
@@ -101,8 +101,8 @@ static int header_check_mov(const unsigned char *buffer, const unsigned int buff
if(buffer[4]=='f' && buffer[5]=='t' && buffer[6]=='y' && buffer[7]=='p')
{
}
- else if(file_recovery!=NULL && file_recovery->file_stat!=NULL &&
- file_recovery->file_stat->file_hint==&file_hint_mov &&
+ else if(file_recovery!=NULL &&
+ file_recovery->data_check==&data_check_mov &&
file_recovery->calculated_file_size == file_recovery->file_size)
{ /* PhotoRec is already trying to recover this mov file */
return 0;
@@ -127,7 +127,7 @@ static int header_check_mov(const unsigned char *buffer, const unsigned int buff
return 0;
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_mov.extension;
- file_recovery_new->data_check=data_check_mov;
+ file_recovery_new->data_check=&data_check_mov;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->calculated_file_size=i+atom_size;
return 1;
@@ -138,7 +138,7 @@ static int header_check_mov(const unsigned char *buffer, const unsigned int buff
return 0;
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_mov.extension;
- file_recovery_new->data_check=data_check_mov;
+ file_recovery_new->data_check=&data_check_mov;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->calculated_file_size=i+atom_size;
return 1;
@@ -154,11 +154,11 @@ static int header_check_mov(const unsigned char *buffer, const unsigned int buff
if(i==0 && buffer[12]=='m' && buffer[13]=='v' && buffer[14]=='h' && buffer[15]=='d')
{
file_recovery_new->calculated_file_size=atom_size;
- file_recovery_new->data_check=data_check_size;
+ file_recovery_new->data_check=&data_check_size;
}
else
*/
- file_recovery_new->data_check=data_check_mov;
+ file_recovery_new->data_check=&data_check_mov;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->calculated_file_size=i+atom_size;
return 1;
@@ -176,7 +176,7 @@ static int header_check_mov(const unsigned char *buffer, const unsigned int buff
{
reset_file_recovery(file_recovery_new);
file_recovery_new->extension="mp4";
- file_recovery_new->data_check=data_check_mov;
+ file_recovery_new->data_check=&data_check_mov;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->calculated_file_size=i+atom_size;
return 1;
@@ -186,7 +186,7 @@ static int header_check_mov(const unsigned char *buffer, const unsigned int buff
reset_file_recovery(file_recovery_new);
/* acc ? */
file_recovery_new->extension="m4p";
- file_recovery_new->data_check=data_check_mov;
+ file_recovery_new->data_check=&data_check_mov;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->calculated_file_size=i+atom_size;
return 1;
@@ -196,7 +196,7 @@ static int header_check_mov(const unsigned char *buffer, const unsigned int buff
/* Video for 3G mobile phone (GSM) */
reset_file_recovery(file_recovery_new);
file_recovery_new->extension="3gp";
- file_recovery_new->data_check=data_check_mov;
+ file_recovery_new->data_check=&data_check_mov;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->calculated_file_size=i+atom_size;
return 1;
@@ -206,7 +206,7 @@ static int header_check_mov(const unsigned char *buffer, const unsigned int buff
/* Video for 3G mobile phone (CDMA) */
reset_file_recovery(file_recovery_new);
file_recovery_new->extension="3g2";
- file_recovery_new->data_check=data_check_mov;
+ file_recovery_new->data_check=&data_check_mov;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->calculated_file_size=i+atom_size;
return 1;
@@ -222,7 +222,7 @@ static int header_check_mov(const unsigned char *buffer, const unsigned int buff
{
reset_file_recovery(file_recovery_new);
file_recovery_new->extension="mov";
- file_recovery_new->data_check=data_check_mov;
+ file_recovery_new->data_check=&data_check_mov;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->file_rename=&file_rename_mov;
file_recovery_new->calculated_file_size=i+atom_size;
@@ -234,7 +234,7 @@ static int header_check_mov(const unsigned char *buffer, const unsigned int buff
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_mov.extension;
file_recovery_new->file_rename=&file_rename_mov;
- file_recovery_new->data_check=data_check_mov;
+ file_recovery_new->data_check=&data_check_mov;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->calculated_file_size=i+atom_size;
return 1;
diff --git a/src/file_mp3.c b/src/file_mp3.c
index 765d9b1..f29b75b 100644
--- a/src/file_mp3.c
+++ b/src/file_mp3.c
@@ -166,8 +166,10 @@ static int header_check_mp3(const unsigned char *buffer, const unsigned int buff
return 0;
if(file_recovery!=NULL && file_recovery->file_stat!=NULL)
{
- if(file_recovery->file_stat->file_hint==&file_hint_mp3 ||
- file_recovery->file_stat->file_hint==&file_hint_mkv)
+ if(file_recovery->data_check==&data_check_mp3 &&
+ file_recovery->calculated_file_size == file_recovery->file_size)
+ return 0;
+ if(file_recovery->file_stat->file_hint==&file_hint_mkv)
return 0;
/* RGV values from TIFF may be similar to the beginning of an mp3 */
if(file_recovery->file_stat->file_hint==&file_hint_tiff &&
diff --git a/src/file_oci.c b/src/file_oci.c
index 5614983..49528cf 100644
--- a/src/file_oci.c
+++ b/src/file_oci.c
@@ -86,7 +86,7 @@ static int header_check_oci(const unsigned char *buffer, const unsigned int buff
{
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_oci.extension;
- file_recovery_new->data_check=data_check_oci;
+ file_recovery_new->data_check=&data_check_oci;
file_recovery_new->file_check=&file_check_size;
return 1;
}
diff --git a/src/file_riff.c b/src/file_riff.c
index e1c591e..0273834 100644
--- a/src/file_riff.c
+++ b/src/file_riff.c
@@ -64,7 +64,7 @@ typedef struct {
static void log_riff_list(const uint64_t offset, const unsigned int depth, const riff_list_header *list_header)
{
unsigned int i;
- log_info("0x%08lx - 0x%08lx ", offset, offset + 8 + le32(list_header->dwSize) - 1);
+ log_info("0x%08lx - 0x%08lx ", offset, offset + 8 - 1 + le32(list_header->dwSize));
for(i = 0; i < depth; i++)
log_info(" ");
log_info("%c%c%c%c %c%c%c%c 0x%x\n",
@@ -84,7 +84,7 @@ static void log_riff_chunk(const uint64_t offset, const unsigned int depth, cons
unsigned int i;
if(le32(list_header->dwSize)==0)
return ;
- log_info("0x%08lx - 0x%08lx ", offset, offset + 8 + le32(list_header->dwSize) - 1);
+ log_info("0x%08lx - 0x%08lx ", offset, offset + 8 - 1 + le32(list_header->dwSize));
for(i = 0; i < depth; i++)
log_info(" ");
log_info("%c%c%c%c 0x%x\n",
@@ -119,7 +119,7 @@ static void check_riff_list(file_recovery_t *fr, const unsigned int depth, const
#ifdef DEBUG_RIFF
log_riff_list(file_size, depth, &list_header);
#endif
- check_riff_list(fr, depth+1, file_size + sizeof(list_header), file_size + 8 + le32(list_header.dwSize) - 1);
+ check_riff_list(fr, depth+1, file_size + sizeof(list_header), file_size + 8 - 1 + le32(list_header.dwSize));
}
else
{
@@ -161,7 +161,7 @@ static void file_check_avi(file_recovery_t *fr)
fr->offset_error=fr->file_size;
return;
}
- check_riff_list(fr, 1, file_size + sizeof(list_header), file_size + 8 + le32(list_header.dwSize) - 1);
+ check_riff_list(fr, 1, file_size + sizeof(list_header), file_size + 8 - 1 + le32(list_header.dwSize));
if(fr->offset_error > 0)
{
fr->file_size=0;
diff --git a/src/file_tib.c b/src/file_tib.c
index cdfae1e..f7c873b 100644
--- a/src/file_tib.c
+++ b/src/file_tib.c
@@ -121,7 +121,7 @@ static int header_check_tib(const unsigned char *buffer, const unsigned int buff
{
reset_file_recovery(file_recovery_new);
file_recovery_new->file_check=&file_check_tib;
- file_recovery_new->data_check=data_check_tib2;
+ file_recovery_new->data_check=&data_check_tib2;
file_recovery_new->extension=file_hint_tib.extension;
return 1;
}