summaryrefslogtreecommitdiffstats
path: root/src/file_gz.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2012-09-10 22:22:20 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2012-09-10 22:22:20 +0200
commit69355438db0dc3c70a4a67423029ec11d78f954c (patch)
tree5e2cd1a4b1a459e9ef4dfacb6ba1ac9de41da5bb /src/file_gz.c
parentf29c37c87b097e8761ec359165f27a0ff786368f (diff)
PhotoRec: recover Minecraft .schematic file
Diffstat (limited to 'src/file_gz.c')
-rw-r--r--src/file_gz.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/file_gz.c b/src/file_gz.c
index 3893ca5..021f10c 100644
--- a/src/file_gz.c
+++ b/src/file_gz.c
@@ -72,14 +72,6 @@ static void register_header_check_gz(file_stat_t *file_stat)
static int header_check_gz(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
{
static const unsigned char tar_header_posix[8] = { 'u','s','t','a','r',' ',' ',0x00};
- static const unsigned char xournal_header[0x2e] = {
- '<', '?', 'x', 'm', 'l', ' ', 'v', 'e',
- 'r', 's', 'i', 'o', 'n', '=', '"', '1',
- '.', '0', '"', ' ', 's', 't', 'a', 'n',
- 'd', 'a', 'l', 'o', 'n', 'e', '=', '"',
- 'n', 'o', '"', '?', '>', '\n', '<', 'x',
- 'o', 'u', 'r', 'n', 'a', 'l'
- };
/* gzip file format:
* a 10-byte header, containing a magic number, a version number and a timestamp
* optional extra headers, such as the original file name,
@@ -122,6 +114,8 @@ static int header_check_gz(const unsigned char *buffer, const unsigned int buffe
#if defined(HAVE_ZLIB_H) && defined(HAVE_LIBZ)
if(buffer_size>off && 512>off)
{
+ static const unsigned char schematic_header[12]={ 0x0a, 0x00, 0x09,
+ 'S', 'c', 'h', 'e', 'm', 'a', 't', 'i', 'c'};
const unsigned char *buffer_compr=buffer+off;
unsigned char buffer_uncompr[512];
const unsigned int comprLen=(buffer_size<512?buffer_size:512)-off;
@@ -164,7 +158,7 @@ static int header_check_gz(const unsigned char *buffer, const unsigned int buffe
file_recovery_new->extension="pvp";
return 1;
}
- if(memcmp(buffer_uncompr, xournal_header, sizeof(xournal_header))==0)
+ if(memcmp(buffer_uncompr, "<?xml version=\"1.0\" standalone=\"no\"?>\n<xournal", 46)==0)
{
/* Xournal, http://xournal.sourceforge.net/ */
file_recovery_new->extension="xoj";
@@ -187,6 +181,12 @@ static int header_check_gz(const unsigned char *buffer, const unsigned int buffe
file_recovery_new->extension="xml.gz";
return 1;
}
+ if(memcmp(buffer_uncompr, schematic_header, sizeof(schematic_header))==0)
+ {
+ /* Minecraft Schematic File */
+ file_recovery_new->extension="schematic";
+ return 1;
+ }
{
unsigned int i;
for(i=0; i<d_stream.total_out && i< 256; i++)