summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2019-04-26 18:47:14 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2019-04-26 18:47:14 +0200
commit7286aaec2ef7983a89ece9d2a59135272d57c175 (patch)
tree2ef8c1eebe0fa118ead7ac759f7af0f3870ef43d /src
parentfd1fe33008bacf9f19bb9e83f6467d61f27b54dd (diff)
PhotoRec: reset offset_skipped_header when this offset belongs to a valid file.
Diffstat (limited to 'src')
-rw-r--r--src/filegen.c6
-rw-r--r--src/filegen.h1
-rw-r--r--src/photorec.c1
3 files changed, 8 insertions, 0 deletions
diff --git a/src/filegen.c b/src/filegen.c
index d6eb2dc..61bd77c 100644
--- a/src/filegen.c
+++ b/src/filegen.c
@@ -597,6 +597,12 @@ int file_rename_unicode(file_recovery_t *file_recovery, const void *buffer, cons
static uint64_t offset_skipped_header=0;
+void header_ignored_cond_reset(uint64_t start, uint64_t end)
+{
+ if(start <= offset_skipped_header && offset_skipped_header <= end)
+ offset_skipped_header=0;
+}
+
/* 0: file_recovery is bad *
* 1: file_recovery is ok */
int header_ignored_adv(const file_recovery_t *file_recovery, const file_recovery_t *file_recovery_new)
diff --git a/src/filegen.h b/src/filegen.h
index af8e793..352a15e 100644
--- a/src/filegen.h
+++ b/src/filegen.h
@@ -135,6 +135,7 @@ void register_header_check(const unsigned int offset, const void *value, const u
file_stat_t * init_file_stats(file_enable_t *files_enable);
int file_rename(file_recovery_t *file_recovery, const void *buffer, const int buffer_size, const int offset, const char *new_ext, const int force_ext);
int file_rename_unicode(file_recovery_t *file_recovery, const void *buffer, const int buffer_size, const int offset, const char *new_ext, const int force_ext);
+void header_ignored_cond_reset(uint64_t start, uint64_t end);
void header_ignored(const file_recovery_t *file_recovery_new);
int header_ignored_adv(const file_recovery_t *file_recovery, const file_recovery_t *file_recovery_new);
int my_fseek(FILE *stream, off_t offset, int whence);
diff --git a/src/photorec.c b/src/photorec.c
index d8b0da1..f98ee43 100644
--- a/src/photorec.c
+++ b/src/photorec.c
@@ -510,6 +510,7 @@ void file_block_free(alloc_list_t *list_allocation)
{
alloc_list_t *allocated_space;
allocated_space=td_list_entry(tmp, alloc_list_t, list);
+ header_ignored_cond_reset(allocated_space->start, allocated_space->end);
free_list_allocation_end=allocated_space->end;
td_list_del(tmp);
free(allocated_space);