8000 No error when trying to extract a single file that is not in archive · Issue #364 · zlib-ng/minizip-ng · GitHub
[go: up one dir, main page]

Skip to content

No error when trying to extract a single file that is not in archive #364

Closed

Description

@gluttony38

Hi,

As we can seen in the sources, in the case of trying to extract a single file that is not in an archive, mz_zip_reader_save_all is supposed to return MZ_END_OF_LIST error:

int32_t minizip_extract(const char *path, const char *patter
8000
n, const char *destination, const char *password, minizip_opt *options)
{
[...]
        /* Save all entries in zip file to destination directory */
        err = mz_zip_reader_save_all(reader, destination);

        if (err == MZ_END_OF_LIST && pattern != NULL)
            printf("Files matching %s not found in zip file\n", pattern);
[...]
}

For example with file ZipExample.zip containing a few files:

ZipExample
├── sourceFile.txt
└── subfolder
    ├── empty
    └── nonempty

If I extract an existing file it actually return MZ_OK (0) but it also returns MZ_OK when trying to extract a non-existing file (and we can see that the "file matching not found" log is not printed):

> ./minizip -x ZipExample.zip subfolder/nonempty
Minizip 2.8.3 - https://github.com/nmoinvaz/minizip
---------------------------------------------------
-x ZipExample.zip subfolder/nonempty 
Archive ZipExample.zip
Extracting subfolder/nonempty
> echo $?
0

> ./minizip -x ZipExample.zip sourceFile.txt
Minizip 2.8.3 - https://github.com/nmoinvaz/minizip
---------------------------------------------------
-x ZipExample.zip sourceFile.txt 
Archive ZipExample.zip
Extracting sourceFile.txt
> echo $?
0

> ./minizip -x ZipExample.zip there/is/no/such/file/in/archive
Minizip 2.8.3 - https://github.com/nmoinvaz/minizip
---------------------------------------------------
-x ZipExample.zip there/is/no/such/file/in/archive 
Archive ZipExample.zip
> echo $?
0

I'm using your lib in a C++ project then I got a easy workaround calling boost::filesystem::is_regular_file(destinationFolder / singleFile) after extract of single file but it would be nice to have mz_zip_reader_save_all actually returning proper error in this case.

Thanks.

Activity

  1. nmoinvaz commented on Feb 13, 2019

    @nmoinvaz
    Member

    I have just made a commit in the dev branch that should fix your issue. Let me know, thanks.

  2. gluttony38 commented on Feb 20, 2019

    @gluttony38
    Author

    Works for me, thanks !

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

    fixedIssue 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