bugGNU Octave - Bugs: bug #67151, unzip does not return correct list...

 
 

bug #67151: unzip does not return correct list of files, it also includes comments

Submitter:  Volkmar Glauche <glauche>
Submitted:  Fri 23 May 2025 02:53:34 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  In Progress Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 10.1.0 Release: 
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 30 May 2025 06:06:54 PM UTC, comment #8: 


comment #7:

> > If so can we use your name + email?
> For the contributors list, just name would suffice.
> For csets we usually include the email in the commit message


We like having the e-mail in the commit message in case there are questions later about the change, how the code works, etc.

Rik <rik5>
Group administrator
Fri 30 May 2025 12:53:30 PM UTC, comment #7: 


> If so can we use your name + email?

For the contributors list, just name would suffice.
For csets we usually include the email in the commit message

Philip Nienhuis <philipnienhuis>
Group Member
Fri 30 May 2025 12:52:08 PM UTC, comment #6: 

@glauche:
Tried the patch in a dev build.
Seems to work fine; no issues with other archive extract functions and pkg.m also passes its BISTs when running 'make check'.
Yet there are some minor syntax thingies. I'll await BIST from you before further actions.
For BISTs, a scratch .zip file with comment(s) must be made, probably using one or more 'system()' calls in the test. Just look at the tests in the various archive/unarchive functions if you can find a suitable example; from there you can copy & adapt it.

Can you prepare a Mercurial changeset rather than a patch? If not, no problems.

AFAICS you're not in the contributors list. Would you like to be credited for your contribution? If so can we use your name + email?

Philip Nienhuis <philipnienhuis>
Group Member
Mon 26 May 2025 07:50:41 PM UTC, comment #5: 

Thanks for quickly picking up.
Quicker than I can respond in the form of testing etc. Hopefully by the end of the week I'll have more time.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 26 May 2025 07:29:21 PM UTC, comment #4: 

Attached is a patch proposal against .../m/miscellaneous/unpack.m. It requires the zip filename to be passed to _parse_zip_ in order to run


system('unzip -z' ...)


on the zip archive before actually working on the unzip output text. This will return only the header lines, and allows _parse_zip_ to skip the correct number of lines.

So far, I haven't written any BIST code for octave, but I'll try to get that done as well.

(file #57242)

Volkmar Glauche <glauche>
Mon 26 May 2025 10:57:16 AM UTC, comment #3: 

First (a bit late - sorry): thanks for reporting.

Confirmed, on Windows with dev Octave (11.0.0).

This appears to be a very old bug, already present in Octave-4.2.0 (oldest I have installed); searching the bug tracker you seem to be the first one to stumble over it. I'll leave Priority at "5 - Normal" for the time being.

Do bzip and gzip also allow comments in archives? (I simply don't know, I never used the option for archives.)  If only unzip is affected the fix may be easier.

Could you come up with a patch or cset?  if possible with a BIST test? You write "it won't be a nice & easy fit" but as this bug is so old there's ample time to think it over.

As to the second issue you mentioned in comment #0 (not overwriting files), you've entered bug #67161 so that will be treated there.

Title adapted.
OS -> Any
Release -> current

Philip Nienhuis <philipnienhuis>
Group Member
Mon 26 May 2025 07:18:27 AM UTC, comment #2: 


Kommentar #1:

> AFAIU you mean that unzip picks the wrong headerline?
> Would you have a better example (run in Octave rather than *nix command line) or a more clear description of the issue, please?


Take the attached example .zip file and extract it with octave: Instead of just returning one line (the filename test.txt), octave will return every line of zip output beginning from line 2, including archive comment lines.


Volkmar Glauche <glauche>
Sun 25 May 2025 02:16:02 PM UTC, comment #1: 

AFAIU you mean that unzip picks the wrong headerline?
Would you have a better example (run in Octave rather than *nix command line) or a more clear description of the issue, please?

W.r.t. the 2nd issue:
In the docs it is stated that "The optional return value is a list of files unpacked" but you want a more explicit list of skipped files, right?
Can you add a separate bug report / feature request for that, please? makes it easier to track down individual issues.

Philip Nienhuis <philipnienhuis>
Group Member
Fri 23 May 2025 02:53:34 PM UTC, original submission:  

There are two issues with the implementation of unzip on Linux.

The attached file test.zip has been created with an additional file comment:


 $ zip -z test.zip test.txt
  adding: test.txt (stored 0%)
enter new zip file comment (end with .):
Test
.


This comment is listed as an additional header line by unzip:


 $ unzip -o test.zip
Archive:  test.zip
Test
 extracting: test.txt


The current implementation of unpack>__parse_zip__ unconditionally assumes the file list to start in line 2 of the output. To get the actual header length, it would be necessary to run an additional command


 $ unzip -z test.zip
Archive:  test.zip
Test


in addition to the actual unzip command. I don't see how this would fit nicely into the current implementation for unpack, though.

The second issue arises because unpack uses unzip -n, which does not overwrite files. In this mode, unzip only lists the files it has actually unpacked. If some files have been skipped, they are not listed even though they are present in the archive and in the unpacked result.

Volkmar Glauche <glauche>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #57242:  unpack_skip_zip_comments.diff added by glauche (1KiB - text/x-patch - Patch to make unpack skip zip archive comments when parsing the list of unpacked files.)
file #57241:  test_multiline_comment.zip added by glauche (203B - application/zip - Additional test archive with a multiline comment (3 header lines in total))
file #57238:  test.zip added by glauche (175B - application/zip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by philipnienhuis (Posted a comment)
  • -email is unavailable- added by glauche (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-05-27 mmuetzel Summaryunzip does not return correct list of files, itialso includes comments unzip does not return correct list of files, it also includes comments
    2025-05-26 philipnienhuis StatusConfirmed In Progress
    2025-05-26 glauche Attached File- Added unpack_skip_zip_comments.diff, #57242
    2025-05-26 philipnienhuis StatusNeed Info Confirmed
        Release9.2.0 10.1.0
        Operating SystemGNU/Linux Any
        Summaryunzip does not return correct list of files unzip does not return correct list of files, itialso includes comments
    2025-05-26 glauche Attached File- Added test_multiline_comment.zip, #57241
    2025-05-25 philipnienhuis StatusNone Need Info
    2025-05-23 glauche Attached File- Added test.zip, #57238

    Back to the top

    Powered by Savane 3.15-26b0.
    Corresponding source code