Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility issues in unzLocateFile #745

Closed
ljavorsk opened this issue Nov 27, 2023 · 6 comments
Closed

Compatibility issues in unzLocateFile #745

ljavorsk opened this issue Nov 27, 2023 · 6 comments
Labels
compatibility Backwards compatibility

Comments

@ljavorsk
Copy link

Hi,

I've run into a building issue with the libdigidocpp package when switching from minizip (madler/zlib part) to minizip-ng (built with MZ_COMPAT flag).

I reported this to their upstream [1], but now when I think about it, it may be the issue of minizip-ng as it should be fully compatible, but it's not.

Could you please take a look at the error and help me resolve this building issue? I was trying to find some sort of PORTING document in your Github, but there is nothing that would look like it.
Thank you

[1] open-eid/libdigidocpp#569

@ljavorsk ljavorsk changed the title Compatibility issues in minizip-ng with COMPAT mode Compatibility issues in minizip-ng with MZ_COMPAT mode Nov 27, 2023
@ljavorsk
Copy link
Author

I've added the #include <zlib.h> to the ZipSerialize.cpp file, as they were counting on minizip to include it.

But now I've encountered another error, which may be the incompatible part of minizip-ng function:
Minizip-ng definition: unzLocateFile(unzFile file, const char *filename, unzFileNameComparer filename_compare_func)
Minizip definition: unzLocateFile OF((unzFile file, const char *szFileName, int iCaseSensitivity))

Error:

/builddir/build/BUILD/libdigidocpp-3.16.0/src/util/ZipSerialize.cpp:139:58: error: invalid conversion from ‘int’ to ‘unzFileNameComparer’ {aka ‘int (*)(void*, const char*, const char*)’} [-fpermissive]
  139 |     int unzResult = unzLocateFile(d->open, file.c_str(), 1);
      |                                                          ^
      |                                                          |
      |                                                          int
In file included from /usr/include/minizip/unzip.h:10,
                 from /builddir/build/BUILD/libdigidocpp-3.16.0/src/util/ZipSerialize.cpp:27:
/usr/include/minizip/mz_compat.h:352:87: note:   initializing argument 3 of ‘int unzLocateFile(unzFile, const char*, unzFileNameComparer)’
  352 | ZEXPORT int     unzLocateFile(unzFile file, const char *filename, unzFileNameComparer filename_compare_func);
      |                                                                   ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/libdigidocpp-3.16.0/src/util/ZipSerialize.cpp: In member function ‘void digidoc::ZipSerialize::addFile(const std::string&, std::istream&, const Properties&, Flags)’:
/builddir/build/BUILD/libdigidocpp-3.16.0/src/util/ZipSerialize.cpp:189:17: error: cannot convert ‘<brace-enclosed initializer list>’ to ‘uint32_t’ {aka ‘unsigned int’} in initialization
  189 |         0, 0, 0 };
      |                 ^
/builddir/build/BUILD/libdigidocpp-3.16.0/src/util/ZipSerialize.cpp: In member function ‘digidoc::ZipSerialize::Properties digidoc::ZipSerialize::properties(const std::string&) const’:
/builddir/build/BUILD/libdigidocpp-3.16.0/src/util/ZipSerialize.cpp:225:58: error: invalid conversion from ‘int’ to ‘unzFileNameComparer’ {aka ‘int (*)(void*, const char*, const char*)’} [-fpermissive]
  225 |     int unzResult = unzLocateFile(d->open, file.c_str(), 1);
      |                                                          ^
      |                                                          |
      |                                                          int
/usr/include/minizip/mz_compat.h:352:87: note:   initializing argument 3 of ‘int unzLocateFile(unzFile, const char*, unzFileNameComparer)’
  352 | ZEXPORT int     unzLocateFile(unzFile file, const char *filename, unzFileNameComparer filename_compare_func);
      |                                                                   ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [src/CMakeFiles/digidocpp.dir/build.make:489: src/CMakeFiles/digidocpp.dir/util/ZipSerialize.cpp.o] Error 1

@nmoinvaz
Copy link
Member

nmoinvaz commented Nov 27, 2023

It appears they are using a another version of minizip that was possibly made by myself. It was not API compatible hence the differences in the unzLocateFile callback. The dev branch is API compatible with the version of minizip in zlib distribution.

@tuliom
Copy link
Contributor

tuliom commented Nov 27, 2023

@nmoinvaz What do you mean with "zlib distribution"?

When I look at madler's minizip (develop branch) I see the 3rd parameter is int iCaseSensitivity.
Source https://github.com/madler/zlib/blob/develop/contrib/minizip/unzip.h#L242-L244

But in minizip-ng, the 3rd parameter is unzFileNameComparer filename_compare_func.
Source: https://github.com/zlib-ng/minizip-ng/blob/develop/mz_compat.h#L352

Isn't that an incompatibility between both projects?

@Neustradamus
Copy link

@nmoinvaz: Have you seen the @tuliom comment?

@nmoinvaz
Copy link
Member

nmoinvaz commented Dec 5, 2023

zlib distribution is https://github.com/madler/zlib.

Hmm, that does look like an incompatibility. Feel free to please submit a PR to fix it.

@nmoinvaz nmoinvaz changed the title Compatibility issues in minizip-ng with MZ_COMPAT mode Compatibility issues in unzLocateFile Dec 6, 2023
@nmoinvaz nmoinvaz added the compatibility Backwards compatibility label Dec 6, 2023
tuliom added a commit to tuliom/minizip-ng that referenced this issue Dec 8, 2023
Replace the previous type with one that is compatible with an int in
order to be identical to the interface used in madler's zlib.

Fixes zlib-ng#745.
tuliom added a commit to tuliom/minizip-ng that referenced this issue Dec 11, 2023
Replace the previous type with one that is compatible with an int in
order to be identical to the interface used in madler's zlib.

Fixes zlib-ng#745.
tuliom added a commit to tuliom/minizip-ng that referenced this issue Dec 11, 2023
Replace the previous type with one that is compatible with an int in
order to be identical to the interface used in madler's zlib.

Fixes zlib-ng#745.
nmoinvaz pushed a commit that referenced this issue Dec 11, 2023
Replace the previous type with one that is compatible with an int in
order to be identical to the interface used in madler's zlib.

Fixes #745.
@tuliom
Copy link
Contributor

tuliom commented Dec 15, 2023

FYI: I can't close this bug, but it has already been fixed by #746 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Backwards compatibility
Projects
None yet
Development

No branches or pull requests

4 participants