[libgsf] zip: fix dirent entry for small files beyond 4GB.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] zip: fix dirent entry for small files beyond 4GB.
- Date: Mon, 1 Dec 2014 18:14:26 +0000 (UTC)
commit dc6b56b6b61ae3feca59738da6aad0fa932e101a
Author: Morten Welinder <terra gnome org>
Date: Mon Dec 1 13:13:45 2014 -0500
zip: fix dirent entry for small files beyond 4GB.
ChangeLog | 6 ++++++
gsf/gsf-outfile-zip.c | 8 ++++----
2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f89cfeb..fab27b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-01 Morten Welinder <terra gnome org>
+
+ * gsf/gsf-outfile-zip.c (zip_dirent_write): Handle the case of
+ small file beyond offset 4G. The header record won't be zip64,
+ but the dirent needs to.
+
2014-11-30 Morten Welinder <terra gnome org>
* gsf/gsf-outfile-zip.c (zip_dirent_write): The the archive is in
diff --git a/gsf/gsf-outfile-zip.c b/gsf/gsf-outfile-zip.c
index 98de1e6..ee0dfcc 100644
--- a/gsf/gsf-outfile-zip.c
+++ b/gsf/gsf-outfile-zip.c
@@ -163,9 +163,9 @@ zip_dirent_write (GsfOutfileZip *zip, const GsfZipDirent *dirent)
gboolean ret;
const guint8 extract = dirent->zip64 ? 45 : 23;
GString *extras = g_string_sized_new (ZIP_DIRENT_SIZE + nlen + 100);
+ gboolean offset_in_zip64 = dirent->offset >= G_MAXUINT32;
- if (dirent->zip64) {
- gboolean do_offset = dirent->offset >= G_MAXUINT32;
+ if (dirent->zip64 || offset_in_zip64) {
char tmp[8];
/*
@@ -176,13 +176,13 @@ zip_dirent_write (GsfOutfileZip *zip, const GsfZipDirent *dirent)
* same.
*/
GSF_LE_SET_GUINT16 (tmp, ZIP_DIRENT_EXTRA_FIELD_ZIP64);
- GSF_LE_SET_GUINT16 (tmp + 2, (2 + do_offset) * 8);
+ GSF_LE_SET_GUINT16 (tmp + 2, (2 + offset_in_zip64) * 8);
g_string_append_len (extras, tmp, 4);
GSF_LE_SET_GUINT64 (tmp, dirent->usize);
g_string_append_len (extras, tmp, 8);
GSF_LE_SET_GUINT64 (tmp, dirent->csize);
g_string_append_len (extras, tmp, 8);
- if (do_offset) {
+ if (offset_in_zip64) {
GSF_LE_SET_GUINT64 (tmp, dirent->offset);
g_string_append_len (extras, tmp, 8);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]