summaryrefslogtreecommitdiffstats
path: root/src/file_gz.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2009-01-22 19:09:33 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2009-01-22 19:09:33 +0100
commitc59351554ceb130a3822caeae17da6c95319e2f4 (patch)
treefd32e7d1edb8438f75ed8627a8e165952ed7fc56 /src/file_gz.c
parent69ba4ed04cb4893e2e9d797a9c5f0b40e1b6edc5 (diff)
PhotoRec: add boundary checking for gz, jpg and pdf
Diffstat (limited to 'src/file_gz.c')
-rw-r--r--src/file_gz.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/file_gz.c b/src/file_gz.c
index 46fa573..a4155f3 100644
--- a/src/file_gz.c
+++ b/src/file_gz.c
@@ -96,11 +96,11 @@ static int header_check_gz(const unsigned char *buffer, const unsigned int buffe
}
if((flags&GZ_FNAME)!=0)
{
- while(buffer[off++]!='\0');
+ while(off<buffer_size && buffer[off++]!='\0');
}
if((flags&GZ_FCOMMENT)!=0)
{
- while(buffer[off++]!='\0');
+ while(off<buffer_size && buffer[off++]!='\0');
}
if((flags&GZ_FHCRC)!=0)
{
@@ -130,7 +130,11 @@ static int header_check_gz(const unsigned char *buffer, const unsigned int buffe
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
if(err!=Z_OK)
+ {
+ /* Decompression has failed, free ressources */
+ inflateEnd(&d_stream);
return 0;
+ }
}
err = inflateEnd(&d_stream);
if(err!=Z_OK)