8000 unzOpenCurrentFile3() always returns zero for `method` and `level` · Issue #289 · zlib-ng/minizip-ng · GitHub
[go: up one dir, main page]

Skip to content

unzOpenCurrentFile3() always returns zero for method and level #289

Closed

Description

@vszakats

Noticed this little difference between minizip's compatibility interface and the original minizip API:

In unzOpenCurrentFile3() the returned method and level values are always zeroes. For method this is just an inconvenience (because it can be retrieved by unzGetCurrentFileInfo64()), but level is important because there is no other way to retrieve it from an existing .zip. The correct level is useful when re-creating an existing entry in raw mode, to make it as much identical to the original as possible.

Activity

  1. nmoinvaz commented on Jul 27, 2018

    @nmoinvaz
    Member

    That should fix it. Let me know if you have any issues.

  2. vszakats commented on Jul 27, 2018

    @vszakats
    ContributorAuthor

    Thank you so much! I can confirm your patches fixed the issue. But... it lead to another one, which luckily seems like a trivial fix: zipOpenNewFileInZip5() resets the received level parameter to zero in raw mode. Vs. original minizip, which leaves it as is, making it possible to control this for raw entries. Fix seems simple:

    diff --git a/mz_compat.c b/mz_compat.c
    index aaf4885658..567dd97cbd 100644
    --- a/mz_compat.c
    +++ b/mz_compat.c
    @@ -185,8 +185,10 @@ extern int ZEXPORT zipOpenNewFileInZip5(zipFile file, const char *filename, cons
             file_info.aes_version = MZ_AES_VERSION;
     #endif
     
    +#if 0
         if (raw)
             level = 0;
    +#endif
     
         return mz_zip_entry_write_open(compat->handle, &file_info, (int16_t)level, password);
     }
  3. vszakats commented on Jul 27, 2018

    @vszakats
    ContributorAuthor

    Opened a PR with (a finalized version of) the above: #291

  4. nmoinvaz commented on Jul 27, 2018

    @nmoinvaz
    Member

    Thanks! I have merged it. Are you using this to delete entries in a zip?

  5. vszakats commented on Jul 27, 2018

    @vszakats
    ContributorAuthor

    Entry deletion is a major "user" of raw mode and there is a high-level wrapper I'm maintaining that's doing just that. I'm not using entry deletion though. My use-case is creating backups while reusing unchanged entries from the previous backup. It can be a nice time saver [0]. (I used to use the command-line zip tool for that, but had to reimplement it from scratch to deal with encrypted input files.)

    [0] Though I'm evaluating a performance drop here just now on a particular system. Not sure where to look yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    compatibilityBackwards compatibilityfixedIssue or bug has been fixed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0