summaryrefslogtreecommitdiffstats
path: root/src/photorec.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2016-01-23 10:29:04 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2016-01-23 10:29:04 +0100
commit7a035acdd1ab72e63af8661aad791cb59d2cb8ed (patch)
tree2c9f0c2dc819e41fea28b046520bfa9131f64a99 /src/photorec.c
parent0675f6f68315c76cc3019e6fa4f34575eee793e1 (diff)
Avoid a file descriptor leak when stopping and resuming PhotoRec
Diffstat (limited to 'src/photorec.c')
-rw-r--r--src/photorec.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/photorec.c b/src/photorec.c
index b05a3e8..0c2229a 100644
--- a/src/photorec.c
+++ b/src/photorec.c
@@ -635,16 +635,22 @@ int file_finish_bf(file_recovery_t *file_recovery, struct ph_param *params,
return 1;
}
-/* file_finish2()
- @param file_recovery -
- @param struct ph_param *params
- const struct ph_options *options
- @param alloc_data_t *list_search_space
+void file_recovery_aborted(file_recovery_t *file_recovery, struct ph_param *params, alloc_data_t *list_search_space)
+{
+ if(file_recovery->file_stat==NULL)
+ return ;
+ params->offset=file_recovery->location.start;
+ if(file_recovery->handle)
+ {
+ fclose(file_recovery->handle);
+ file_recovery->handle=NULL;
+ /* File is zero-length; erase it */
+ unlink(file_recovery->filename);
+ }
+ file_block_truncate_zero(file_recovery, list_search_space);
+ reset_file_recovery(file_recovery);
+}
- @returns:
- 0: file not recovered
- 1: file recovered
- */
pfstatus_t file_finish2(file_recovery_t *file_recovery, struct ph_param *params, const int paranoid, alloc_data_t *list_search_space)
{
int file_truncated;