Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 716678326652323db0787210b0e05e1dce8d018710e674376bb4cba52e5debac
Ticket: 26547532af7fb7d24b2cd101b85abdb1a1af6291
zipfs offsets are a problem
User & Date: juliannoble2 on 2024-10-11 06:37:49
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-plain"
  4. comment changed to:
    It's long established in the windows world at least that executables can be joined to the beginning of a zipfile by simple catenation.
    
      cat some.exe some.zip > exewithzip.exe
    
    Various programs use this.. e.g just a random example: https://jasonliang.js.org/fusing.html
     but it shows an equivalent method: 
      copy /b input.exe+input.zip exewithzip.exe
    
    These exewithzip.exe files can be easily updated either on commandline or through the graphical interface with common tools such as 7-zip and PeaZip.
    
    On the other hand files with executables that have been made by the current implementation of zipfs mkimg - or info-zip's 'zip -A' option cannot be updated either graphically or on the commandline with such tools.
    
    Worse - info-zips 'zip -A cattedzip.exe' refused to adjust the offsets anyway when I tried it on windows and suggests trying -FF - which is a terrible idea because it just produces a zip with the exe part stripped off.
    
    As venerable and widespread as info-zip is - there are multiple versions with slightly different behaviour and the project seems to be slow to release (glass houses.. but anyway)
    
    As poorly specified as the zip format is - I don't see any justification for info-zips choice to treat offset from the beginning of the file as preferential vs offsets from where the zip archive starts in the file.
    The pkware appnotes just say:
    "Offset of the start of the central directory on the
          disk on which the central directory starts."
    
    Which is a reference to the old practice of splitting zips across floppies - but says nothing about adjusting offsets for prefix data.
    
    I think info-zips choice and lack of interoperability flies in the face of common practice. (one I believe recognized by pkware but not really clarified)
    
    Tools like 7z are aware of exezips with prefixed data and report it in an unalarming way as:
    Offset = xxxx
    
    or.. for an 'adjusted' file produced by zipfs mkzip or zip -A
    Embedded Stub Size = xxxx
    
    It can be argued that their choice to cowardly refuse to update a file with un-headered data *within* the range pointed to by the offset is just a different and opposite choice to info-zip's - but I'd argue that info-zip's choice is more cowardly in that the data is clearly separate and a *common* case - and 7z,peazip is just conservative about not breaking something that isn't well understood. 
    
    zip files are scanned by looking for the end of central directory record from the back - and the offsets can be processed from there. No requirement that the offset must be relative to the start of the file is established and I don't think we should reinforce info-zip's take on it.
    
    
    info-zip's unzip utility chooses not to display the Embedded Stub size on such a file - treating that as somehow 'normal' (it's not disallowed - but there's no justification for treating it as the preferred way)
    
    .. but it chooses to display an offset relative to the start of the zip-portion in an 'alarming' manner:
    warning [catted_only.exe]:  xxxx extra bytes at beginning or within zipfile
    (attempting to process anyway)
    
    
    My case is that we shouldn't let info-zip's choices drive the decision - and that preserving interoperability of plain catted prefix (whether it be a tcl script + ctrl-z + zip or exe + zip) is more important.
    
    7z is available on windows,BSDs,linux and I believe also Macs.
    
    unzipping catted exezips doesn't seem to be a problem with the tools I tested either 'adjusted' or not.
    
    My patch attached to ticket: https://core.tcl-lang.org/tcl/tktview/ad7bafd5e1 (though not really the right place for the core topic of that ticket)  works for me on windows but I would like to hear arguments about why the offset adjustments are being made.
    
    ticket: https://core.tcl-lang.org/tcl/tktview/fc65ff1b663fd16e7582  is where the adjustments were changed from being relative to the zip-archive start to relative to the file start.
    The way we used to have them (relative to archive start) is I think the better way.
    The issue in that ticket was about 'zipfs mkimg' failing to output the executable part at all under linux static builds - but whatever caused that should be independent of how the offsets are written.
    
  5. is_private changed to: "0"
  6. login: "juliannoble2"
  7. priority changed to: "5 Medium"
  8. private_contact changed to: "957fdfcd8744611e3fe1f4896c7538b1d9bf47b2"
  9. resolution changed to: "None"
  10. severity changed to: "Severe"
  11. status changed to: "Open"
  12. submitter changed to: "juliannoble2"
  13. subsystem changed to: "- New Builtin Commands"
  14. title changed to: "zipfs offsets are a problem"
  15. type changed to: "Bug"