[libgsf] Zip: resolve dirent's zip64 from auto to FALSE after rewriting final header



commit f1242db1b3d5ff09e02711ddffd1f171225971b6
Author: Morten Welinder <terra gnome org>
Date:   Sun Nov 30 19:21:37 2014 -0500

    Zip: resolve dirent's zip64 from auto to FALSE after rewriting final header
    
    If we get this far with auto, we don't need a zip64 field.  Resolving it
    to solve signals the trailer writing code not to use a zip64 field either,
    unless it is needed for the offset.

 ChangeLog             |    2 ++
 gsf/gsf-outfile-zip.c |   18 +++++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d0167dc..b89336a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@
        dirent as being zip64.
        (zip_close_root): If any dirent is zip64, the archive is.
        (zip_output_block): Catch overflow of csize.
+       (zip_header_patch_sizes): Resolve zip64 to FALSE if it remained
+       auto until now.
 
 2014-11-29  Morten Welinder  <terra gnome org>
 
diff --git a/gsf/gsf-outfile-zip.c b/gsf/gsf-outfile-zip.c
index 2c95d09..552529b 100644
--- a/gsf/gsf-outfile-zip.c
+++ b/gsf/gsf-outfile-zip.c
@@ -694,11 +694,23 @@ zip_header_patch_sizes (GsfOutfileZip *zip)
 {
        GsfZipDirent *dirent = zip->vdir->dirent;
        gsf_off_t pos = gsf_output_tell (zip->sink);
+       gboolean ok;
 
        /* Rewrite the header in the same location again.  */
-       return (gsf_output_seek (zip->sink, dirent->offset, G_SEEK_SET) &&
-               zip_header_write (zip) &&
-               gsf_output_seek (zip->sink, pos, G_SEEK_SET));
+       ok = (gsf_output_seek (zip->sink, dirent->offset, G_SEEK_SET) &&
+             zip_header_write (zip) &&
+             gsf_output_seek (zip->sink, pos, G_SEEK_SET));
+
+       if (ok && dirent->zip64 == -1) {
+               /*
+                * We just wrote the final header.  Since we still are in
+                * auto-mode, the header did not use a real zip64 extra
+                * field.  Hence we don't need such a field.
+                */
+               dirent->zip64 = FALSE;
+       }
+
+       return ok;
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]