summaryrefslogtreecommitdiffstats
path: root/src/photorec.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-10-28 11:22:22 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2014-10-28 11:22:22 +0100
commit319e5b55cb07b787f0f673a1ac0e7c72bf8f3d12 (patch)
tree935f5bb9c1726da726f75a89fb78c0b05d604474 /src/photorec.c
parent3e91667fb243d0f7518f425faf92a46a2cdf573b (diff)
PhotoRec: fix file descriptor leak when bruteforce mode is enabled
Diffstat (limited to 'src/photorec.c')
-rw-r--r--src/photorec.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/photorec.c b/src/photorec.c
index 342ef3e..9d12907 100644
--- a/src/photorec.c
+++ b/src/photorec.c
@@ -618,6 +618,11 @@ int file_finish_bf(file_recovery_t *file_recovery, struct ph_param *params,
if(file_recovery->offset_error!=0)
return -1;
file_block_truncate_zero(file_recovery, list_search_space);
+ if(file_recovery->handle!=NULL)
+ {
+ fclose(file_recovery->handle);
+ unlink(file_recovery->filename);
+ }
reset_file_recovery(file_recovery);
return 0;
}
@@ -627,7 +632,6 @@ int file_finish_bf(file_recovery_t *file_recovery, struct ph_param *params,
xml_log_file_recovered(file_recovery);
#endif
file_block_free(&file_recovery->location);
- reset_file_recovery(file_recovery);
return 1;
}
@@ -647,7 +651,7 @@ int file_finish2(file_recovery_t *file_recovery, struct ph_param *params, const
if(file_recovery->file_stat==NULL)
return 0;
if(file_recovery->handle)
- file_finish_aux(file_recovery, params, paranoid);
+ file_finish_aux(file_recovery, params, (paranoid==0?0:1));
if(file_recovery->file_size==0)
{
file_block_truncate_zero(file_recovery, list_search_space);