summaryrefslogtreecommitdiffstats
path: root/src/file_gz.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2008-10-08 08:53:37 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2008-10-08 08:53:37 +0200
commit2a2526f1bd8c1d20207dc834c663e3985c63e60a (patch)
tree1708b0d57eaf33c25fc1bf4b1d883b38c6cbd0c0 /src/file_gz.c
parentde6f50d0a3c063bf753843f17b1b819f462e5c42 (diff)
PhotoRec: recover tar.gz with the correct extension instead of .gz
Diffstat (limited to 'src/file_gz.c')
-rw-r--r--src/file_gz.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/file_gz.c b/src/file_gz.c
index 66e809d..0d679a9 100644
--- a/src/file_gz.c
+++ b/src/file_gz.c
@@ -47,6 +47,7 @@ const file_hint_t file_hint_gz= {
};
static const unsigned char gz_header_magic[3]= {0x1F, 0x8B, 0x08};
+static const unsigned char tar_header_posix[8] = { 'u','s','t','a','r',' ',' ',0x00};
static void register_header_check_gz(file_stat_t *file_stat)
{
@@ -135,30 +136,36 @@ static int header_check_gz(const unsigned char *buffer, const unsigned int buffe
if(err!=Z_OK)
return 0;
buffer_uncompr[d_stream.total_out]='\0';
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->min_filesize=22;
+ file_recovery_new->time=buffer[4]|(buffer[5]<<8)|(buffer[6]<<16)|(buffer[7]<<24);
if(strstr((const char*)&buffer_uncompr, "<!DOCTYPE KMYMONEY-FILE>")!=NULL)
{
- reset_file_recovery(file_recovery_new);
- file_recovery_new->min_filesize=22;
- file_recovery_new->time=buffer[4]|(buffer[5]<<8)|(buffer[6]<<16)|(buffer[7]<<24);
file_recovery_new->extension="kmy";
return 1;
}
if(memcmp(buffer_uncompr, "PVP ", 4)==0)
{
/* php Video Pro */
- reset_file_recovery(file_recovery_new);
- file_recovery_new->min_filesize=22;
- file_recovery_new->time=buffer[4]|(buffer[5]<<8)|(buffer[6]<<16)|(buffer[7]<<24);
file_recovery_new->extension="pvp";
return 1;
}
+ if(d_stream.total_out>0x110 &&
+ memcmp(&buffer_uncompr[0x101],tar_header_posix,sizeof(tar_header_posix))==0)
+ {
+ file_recovery_new->extension="tar.gz";
+ return 1;
+ }
+ file_recovery_new->extension=file_hint_gz.extension;
+ return 1;
}
-#endif
+#else
reset_file_recovery(file_recovery_new);
file_recovery_new->min_filesize=22;
file_recovery_new->time=buffer[4]|(buffer[5]<<8)|(buffer[6]<<16)|(buffer[7]<<24);
file_recovery_new->extension=file_hint_gz.extension;
return 1;
+#endif
}
return 0;
}