summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2016-02-25 14:04:26 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2016-02-25 14:04:26 +0100
commitfb8c132b70aec83c1a7cefcbe52e1d31ff0b109c (patch)
tree825513d96d3c61a618c072bfb89f6d78569a001a
parentcc7f97cd2931bf65f68754031681f1a1e20046fa (diff)
PhotoRec: do not limit .raf filesize for recent version
-rw-r--r--src/file_dad.c2
-rw-r--r--src/file_jsonlz4.c2
-rw-r--r--src/file_m2ts.c4
-rw-r--r--src/file_raf.c3
-rw-r--r--src/file_riff.c2
-rw-r--r--src/file_swf.c2
-rw-r--r--src/filegen.c8
-rw-r--r--src/filegen.h3
8 files changed, 16 insertions, 10 deletions
diff --git a/src/file_dad.c b/src/file_dad.c
index fb99bc4..f4e5794 100644
--- a/src/file_dad.c
+++ b/src/file_dad.c
@@ -89,7 +89,7 @@ static int header_check_dad(const unsigned char *buffer, const unsigned int buff
if(file_recovery_new->blocksize >= 16)
{
file_recovery_new->data_check=&data_check_dad;
- file_recovery_new->file_check=&file_check_size_lax;
+ file_recovery_new->file_check=&file_check_size_max;
}
return 1;
}
diff --git a/src/file_jsonlz4.c b/src/file_jsonlz4.c
index 7dc960f..8d3390e 100644
--- a/src/file_jsonlz4.c
+++ b/src/file_jsonlz4.c
@@ -51,7 +51,7 @@ static int header_check_jsonlz4(const unsigned char *buffer, const unsigned int
file_recovery_new->extension=file_hint_jsonlz4.extension;
file_recovery_new->calculated_file_size=le32(*uncompressed_size);
file_recovery_new->data_check=&data_check_size;
- file_recovery_new->file_check=&file_check_size_lax;
+ file_recovery_new->file_check=&file_check_size_max;
return 1;
}
diff --git a/src/file_m2ts.c b/src/file_m2ts.c
index 1eda27a..0b150ad 100644
--- a/src/file_m2ts.c
+++ b/src/file_m2ts.c
@@ -149,7 +149,7 @@ static int header_check_m2ts(const unsigned char *buffer, const unsigned int buf
return 1;
file_recovery_new->calculated_file_size=0;
file_recovery_new->data_check=&data_check_ts_192;
- file_recovery_new->file_check=&file_check_size_lax;
+ file_recovery_new->file_check=&file_check_size_max;
return 1;
}
@@ -184,7 +184,7 @@ static int header_check_m2t(const unsigned char *buffer, const unsigned int buff
file_recovery_new->min_filesize=188;
file_recovery_new->calculated_file_size=0;
file_recovery_new->data_check=&data_check_ts_188;
- file_recovery_new->file_check=&file_check_size_lax;
+ file_recovery_new->file_check=&file_check_size_max;
file_recovery_new->file_rename=&file_rename_ts_188;
return 1;
}
diff --git a/src/file_raf.c b/src/file_raf.c
index dbae6b6..7912485 100644
--- a/src/file_raf.c
+++ b/src/file_raf.c
@@ -31,7 +31,6 @@
#include "common.h"
#include "filegen.h"
-
static void register_header_check_raf(file_stat_t *file_stat);
const file_hint_t file_hint_raf= {
@@ -92,7 +91,7 @@ static int header_check_raf(const unsigned char *buffer, const unsigned int buff
else
{
/* The size is bigger than calculated_file_size */
- file_recovery_new->file_check=&file_check_size_lax;
+ file_recovery_new->file_check=&file_check_size_min;
}
return 1;
}
diff --git a/src/file_riff.c b/src/file_riff.c
index 3ecfc61..d029431 100644
--- a/src/file_riff.c
+++ b/src/file_riff.c
@@ -267,7 +267,7 @@ static int header_check_riff(const unsigned char *buffer, const unsigned int buf
if(file_recovery_new->blocksize < 8)
return 1;
file_recovery_new->data_check=&data_check_avi_stream;
- file_recovery_new->file_check=&file_check_size_lax;
+ file_recovery_new->file_check=&file_check_size_max;
}
else
{
diff --git a/src/file_swf.c b/src/file_swf.c
index d0165eb..436bdb1 100644
--- a/src/file_swf.c
+++ b/src/file_swf.c
@@ -138,7 +138,7 @@ static int header_check_swfc(const unsigned char *buffer, const unsigned int buf
file_recovery_new->extension="swc";
file_recovery_new->calculated_file_size=le32(hdr->size);
file_recovery_new->data_check=&data_check_size;
- file_recovery_new->file_check=&file_check_size_lax;
+ file_recovery_new->file_check=&file_check_size_max;
return 1;
}
diff --git a/src/filegen.c b/src/filegen.c
index ed9eb3e..c7bfe83 100644
--- a/src/filegen.c
+++ b/src/filegen.c
@@ -291,7 +291,13 @@ void file_check_size(file_recovery_t *file_recovery)
file_recovery->file_size=file_recovery->calculated_file_size;
}
-void file_check_size_lax(file_recovery_t *file_recovery)
+void file_check_size_min(file_recovery_t *file_recovery)
+{
+ if(file_recovery->file_size<file_recovery->calculated_file_size)
+ file_recovery->file_size=0;
+}
+
+void file_check_size_max(file_recovery_t *file_recovery)
{
if(file_recovery->file_size > file_recovery->calculated_file_size)
file_recovery->file_size=file_recovery->calculated_file_size;
diff --git a/src/filegen.h b/src/filegen.h
index 2ab5e64..ed12995 100644
--- a/src/filegen.h
+++ b/src/filegen.h
@@ -125,8 +125,9 @@ void file_search_footer(file_recovery_t *file_recovery, const void*footer, const
void file_search_lc_footer(file_recovery_t *file_recovery, const unsigned char*footer, const unsigned int footer_length);
void del_search_space(alloc_data_t *list_search_space, const uint64_t start, const uint64_t end);
data_check_t data_check_size(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery);
-void file_check_size_lax(file_recovery_t *file_recovery);
void file_check_size(file_recovery_t *file_recovery);
+void file_check_size_min(file_recovery_t *file_recovery);
+void file_check_size_max(file_recovery_t *file_recovery);
void reset_file_recovery(file_recovery_t *file_recovery);
void register_header_check(const unsigned int offset, const void *value, const unsigned int length, int (*header_check)(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),