summaryrefslogtreecommitdiffstats
path: root/src/file_zip.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2016-09-23 13:57:32 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2016-09-23 13:57:32 +0200
commitb947e58fa0a049692202e04d14992d5d829d5356 (patch)
tree062b708d4e5bf7efd7e0bdb0b35cf55e5f543476 /src/file_zip.c
parent8a37700513c6e8d380365b8581ce005932dbb857 (diff)
PhotoRec: when a zip header is found while Photorec is already recovering a zip file, check this file. (speed optimization)
Diffstat (limited to 'src/file_zip.c')
-rw-r--r--src/file_zip.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/file_zip.c b/src/file_zip.c
index a217f87..539ec2b 100644
--- a/src/file_zip.c
+++ b/src/file_zip.c
@@ -793,8 +793,22 @@ static int header_check_zip(const unsigned char *buffer, const unsigned int buff
file_recovery->file_stat->file_hint==&file_hint_zip &&
safe_header_only==0)
{
- header_ignored(file_recovery_new);
- return 0;
+ file_recovery_t fr_test;
+ off_t offset;
+ memcpy(&fr_test, file_recovery, sizeof(fr_test));
+#ifdef HAVE_FTELLO
+ if((offset=ftello(file_recovery->handle)) == -1)
+ offset=ftell(file_recovery->handle);
+#else
+ offset=ftell(file_recovery->handle);
+#endif
+ file_check_zip(&fr_test);
+ fseek(file_recovery->handle, offset, SEEK_SET);
+ if(fr_test.file_size==0)
+ {
+ header_ignored(file_recovery_new);
+ return 0;
+ }
}
reset_file_recovery(file_recovery_new);
file_recovery_new->min_filesize=21;