summaryrefslogtreecommitdiffstats
path: root/src/phrecn.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-03-31 09:32:17 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2013-03-31 09:32:17 +0200
commit5b6ff07ea7d50b959a6b0fd073e2d4612a4fbc06 (patch)
treecacdaa8acdf29ad81a1a60d0a6cb95e9b8fe5b51 /src/phrecn.c
parentbf8739f75a4d62f56192611e848238a5751f3724 (diff)
PhotoRec: limit the number of times PhotoRec moves backward to recover to the previous fragmented files
Diffstat (limited to 'src/phrecn.c')
-rw-r--r--src/phrecn.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/phrecn.c b/src/phrecn.c
index e605584..ede75c8 100644
--- a/src/phrecn.c
+++ b/src/phrecn.c
@@ -202,6 +202,8 @@ static int photorec_aux(struct ph_param *params, const struct ph_options *option
unsigned int buffer_size;
const unsigned int blocksize=params->blocksize;
const unsigned int read_size=(blocksize>65536?blocksize:65536);
+ uint64_t offset_before_back=0;
+ unsigned int back=0;
alloc_data_t *current_search_space;
file_recovery_t file_recovery;
memset(&file_recovery, 0, sizeof(file_recovery));
@@ -421,11 +423,18 @@ static int photorec_aux(struct ph_param *params, const struct ph_options *option
else if(file_recovered==0)
{
get_next_sector(list_search_space, &current_search_space,&offset,blocksize);
+ if(offset > offset_before_back)
+ back=0;
}
else if(file_recovered>0)
{
/* try to recover the previous file, otherwise stay at the current location */
- get_prev_file_header(list_search_space, &current_search_space, &offset);
+ offset_before_back=offset;
+ if(back < 10 &&
+ get_prev_file_header(list_search_space, &current_search_space, &offset)==0)
+ back++;
+ else
+ back=0;
}
if(current_search_space==list_search_space)
{