vmchale / libarchive

Haskell bindings to libarchive

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Corrupted zip unpacking?

hasufell opened this issue · comments

On windows using the bundled sources, I'm not able to unpack the following archive without the executable being corrupted:

https://downloads.haskell.org/~cabal/cabal-install-3.2.0.0/cabal-install-3.2.0.0-x86_64-unknown-mingw32.zip

Ok, so I tried with using the system package on windows via mingw: https://packages.msys2.org/package/mingw-w64-x86_64-libarchive?repo=mingw64

It seems this unpacks it correctly. So something must be off with the bundled sources configuration.

Could it be the lack of zstd?

ok, I tracked it down to the lack of zlib support!

If I do

diff --git a/c/autoconf-linux/config.h b/c/autoconf-linux/config.h
index 7389c80..43f3dcc 100644
--- a/c/autoconf-linux/config.h
+++ b/c/autoconf-linux/config.h
@@ -681,7 +681,7 @@
 /* #undef HAVE_LIBXML_XMLWRITER_H */

 /* Define to 1 if you have the `z' library (-lz). */
-/* #undef HAVE_LIBZ */
+#define HAVE_LIBZ 1

 /* Define to 1 if you have the `zstd' library (-lzstd). */
 /* #undef HAVE_LIBZSTD */
@@ -1213,7 +1213,7 @@
 #define HAVE_WORKING_FS_IOC_GETFLAGS 1

 /* Define to 1 if you have the <zlib.h> header file. */
-/* #undef HAVE_ZLIB_H */
+#define HAVE_ZLIB_H 1

 /* Define to 1 if you have the <zstd.h> header file. */
 /* #undef HAVE_ZSTD_H */
diff --git a/libarchive.cabal b/libarchive.cabal
index efd2c03..838e160 100644
--- a/libarchive.cabal
+++ b/libarchive.cabal
@@ -262,6 +262,7 @@ library
         include-dirs: c/

         cc-options: -std=c11 -DHAVE_CONFIG_H
+        pkgconfig-depends: zlib
     else
         pkgconfig-depends: libarchive (==3.5.0 || >3.5.0) && <4.0

it will unpack the zip files correctly. However, now we suddenly have a dependency on zlib 😕

Would it be an option to bundle zlib as well? It's fairly small.