[libgsf] Zip: fix typo for reading certain zip files.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] Zip: fix typo for reading certain zip files.
- Date: Sun, 23 Nov 2014 21:53:03 +0000 (UTC)
commit e3c6c9118bc4d6ad88bdaa3ec63967638fa4b73b
Author: Morten Welinder <terra gnome org>
Date: Sun Nov 23 16:52:01 2014 -0500
Zip: fix typo for reading certain zip files.
This somehow affected xlsx files more than other files.
ChangeLog | 2 ++
gsf/gsf-infile-zip.c | 5 +++--
gsf/gsf-zip-impl.h | 1 +
3 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b955088..9dc6c91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
* gsf/gsf-infile-zip.c (zip_dirent_new_in): Fix reading of
extended field. csize and usize are swapped in there.
+ (zip_dirent_new_in): Read the right amount of variable data.
+ (zip_read_dirents): Check trailer64 signature.
* gsf/gsf-outfile-zip.c (zip_dirent_write): Fix file mode.
diff --git a/gsf/gsf-infile-zip.c b/gsf/gsf-infile-zip.c
index edb5d31..64b94d9 100644
--- a/gsf/gsf-infile-zip.c
+++ b/gsf/gsf-infile-zip.c
@@ -269,7 +269,7 @@ zip_dirent_new_in (GsfInfileZip *zip, gsf_off_t *offset)
vlen = name_len + extras_len + comment_len;
/* Read variable part */
- variable = gsf_input_read (zip->source, ZIP_DIRENT_SIZE, NULL);
+ variable = gsf_input_read (zip->source, vlen, NULL);
if (!variable && vlen > 0)
return NULL;
if (FALSE && variable) gsf_mem_dump (variable, vlen);
@@ -426,7 +426,8 @@ zip_read_dirents (GsfInfileZip *zip)
if (gsf_input_seek (zip->source, zip64_eod_offset, G_SEEK_SET))
goto bad;
data = gsf_input_read (zip->source, ZIP_TRAILER64_SIZE, NULL);
- if (!data)
+ if (!data ||
+ GSF_LE_GET_GUINT32 (data) != ZIP_TRAILER64_SIGNATURE)
goto bad;
entries = GSF_LE_GET_GUINT64 (data + ZIP_TRAILER64_ENTRIES);
diff --git a/gsf/gsf-zip-impl.h b/gsf/gsf-zip-impl.h
index ab2d71a..29a01d3 100644
--- a/gsf/gsf-zip-impl.h
+++ b/gsf/gsf-zip-impl.h
@@ -55,6 +55,7 @@ G_BEGIN_DECLS
#define ZIP_ZIP64_LOCATOR_OFFSET 8
#define ZIP_ZIP64_LOCATOR_DISKS 16
+#define ZIP_TRAILER64_SIGNATURE 0x06064b50
#define ZIP_TRAILER64_SIZE 56 /* or more */
#define ZIP_TRAILER64_RECSIZE 4
#define ZIP_TRAILER64_ENCODER 12
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]