Menu

#64 vfs::zip fails when a file > 2GB exists in archive

open
nobody
5
2008-12-30
2008-12-30
No

Trying to list a 8 GB zip file containing several 2GB files leads to:
error during seek on "file5": invalid argument
while executing
"::zip::open [::file normalize $zipfile]"
(procedure "vfs::zip::Mount" line 2)
invoked from within
"vfs::zip::Mount $inpfile ZIP"
invoked from within
"set fd [vfs::zip::Mount $inpfile ZIP]"
(file "./list_zip.tcl" line 101)

It seems to come from a 32-bit signed/unsigned missmatch in function zip::EndOfArchive - I've added some debug output and changed the value for cb(coff) to an unsigned value:
DEBUG: header filepos=490
DEBUG: $hdr=00000000060006006a0200002511bec20000
DEBUG: scan $hdr ssssiis cb(ndisk) cb(cdisk) cb(nitems) cb(ntotal) cb(csize) cb(coff) cb(comment)
DEBUG: cb(ndisk) = 0000 0
DEBUG: cb(cdisk) = 0000 0
DEBUG: cb(nitems) = 0600 6
DEBUG: cb(ntotal) = 0600 6
DEBUG: cb(csize) = 6a020000 618
DEBUG: cb(coff) = 2511bec2 -1027731163
DEBUG: cb(comment) = 0000 0
DEBUG: cb(coff) unsigned 3267236133
DEBUG: before: seek file5 3267236133 start
DEBUG: after: seek...
bad central header: f5ef215f
while executing
"::zip::open [::file normalize $zipfile]"
(procedure "vfs::zip::Mount" line 2)
invoked from within
"vfs::zip::Mount $inpfile ZIP"
invoked from within
"set fd [vfs::zip::Mount $inpfile ZIP]"
(file "./list_zip.tcl" line 102)

Errors occurred in : list_zip.tcl

Discussion

  • Gerhard Reithofer

    ZIP file lister

     
  • Gerhard Reithofer

    Unsigned filesize patch

     
  • Gerhard Reithofer

    Files larger than 2GB lead to invalid negative file offsets because the zip header entries are interpreted signed (scan format code "i").
    The patch zip-1.0.1.tm.patch changes all file size related binary scan codes "i" to unsigned "iu".
    I don't know if the CRC32 word is interpreted correct with "i".

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.