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

"zfsize < zs.size" error for libzip-1.1.2 #43

Closed
gennadykr opened this issue Apr 12, 2016 · 8 comments
Closed

"zfsize < zs.size" error for libzip-1.1.2 #43

gennadykr opened this issue Apr 12, 2016 · 8 comments

Comments

@gennadykr
Copy link

I got an error like in issue #38 when use libzip-1.1.2.
But for libzip-0.11.2 there are no errors.

Making all in src
CC ideviceinstaller-ideviceinstaller.o
ideviceinstaller.c:924:73: error: format specifies type 'long long' but the argument has type 'ssize_t' (aka 'long') [-Werror,-Wformat]
fprintf(stderr, "Error: wrote only %d of %" PRIi64 "\n", total, amount);
~~~ ^~~~~~
ideviceinstaller.c:906:20: error: comparison of integers of different signs: 'off_t' (aka 'long long') and 'zip_uint64_t' (aka 'unsigned long long') [-Werror,-Wsign-compare]
while (zfsize < zs.size) {
~~~~~~ ^ ~~~~~~~
2 errors generated.
make[2]: *** [ideviceinstaller-ideviceinstaller.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

@andrewmichaelsmith
Copy link

andrewmichaelsmith commented May 21, 2016

Also seeing this on Ubuntu 16.04 with libzip 1.0.1.

#38 was closed saying to use libzip >= 0.10, I assume the 1.0 libzip change is what broke this:

➜  ideviceinstaller git:(master) ✗ make
make  all-recursive
make[1]: Entering directory '/home/andrew/git/ideviceinstaller'
Making all in src
make[2]: Entering directory '/home/andrew/git/ideviceinstaller/src'
  CC       ideviceinstaller-ideviceinstaller.o
ideviceinstaller.c: In function ‘main’:
ideviceinstaller.c:906:20: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
      while (zfsize < zs.size) {
                    ^
cc1: all warnings being treated as errors
➜  ideviceinstaller git:(master) ✗ dpkg -s libzip-dev
Package: libzip-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 419
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Multi-Arch: same
Source: libzip
Version: 1.0.1-0ubuntu1

The following patch will get it building but I then get the error Could not start com.apple.mobile.installation_proxy!, and I'm not clear if that's because of my tinkering with the build flags:

diff --git a/configure.ac b/configure.ac
index 52d2a5d..3839896 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,7 @@ if test "x${have_lstat}" = "xyes" ; then
   AC_DEFINE([HAVE_LSTAT], 1, [Define if lstat syscall is supported])
 fi

-AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith  -Wwrite-strings -Wswitch-default -Wno-unused-parameter -Werror -g")
+AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith  -Wwrite-strings -Wswitch-default -Wno-unused-parameter -g")
 AC_SUBST(GLOBAL_CFLAGS)

 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])

@sohgoh
Copy link

sohgoh commented Jun 29, 2016

Hi, I got same error with libzip 1.1.2 on OSX 10.12 Beta (16A201w).
The follow patch will get success to build and run ideviceinstaller command.

diff --git a/src/ideviceinstaller.c b/src/ideviceinstaller.c
index f70ba25..e9c4a82 100644
--- a/src/ideviceinstaller.c
+++ b/src/ideviceinstaller.c
@@ -903,7 +903,7 @@ run_again:
                                        dstpath = NULL;

                                        zip_uint64_t zfsize = 0;
-                                       while (zfsize < zs.size) {
+                                       while (zfsize < (zip_int64_t)zs.size) {
                                                zip_int64_t amount = zip_fread(zfile, buf, sizeof(buf));
                                                if (amount == 0) {
                                                        break;
@@ -921,7 +921,7 @@ run_again:
                                                                total += written;
                                                        }
                                                        if (total != amount) {
-                                                               fprintf(stderr, "Error: wrote only %d of %" PRIi64 "\n", total, amount);
+                                                               fprintf(stderr, "Error: wrote only %d of %" PRIi64 "\n", total, (uint64_t)amount);
                                                                afc_file_close(afc, af);
                                                                zip_fclose(zfile);
                                                                free(dstpath);

@paulvojta
Copy link
Contributor

The problem is on line 54: #ifndef ZIP_CODEC_ENCODE
In Version 0.10.1-1.2 of libzip-dev (on Ubuntu), the file /usr/include/zip.h defines ZIP_CODEC_ENCODE, but in Version 1.1.2-1.1 (on Debian), this is not defined.
One way to fix the bug would be to replace line 54 with something like
#if !(defined(ZIP_CODEC_ENCODE) || LIBZIP_VERSION_MAJOR > 0 || LIBZIP_VERSION_MINOR >= 10)
It would be better to have a test based solely on the version number, but I don't know what the cutoff is.

@shusso
Copy link

shusso commented Sep 13, 2016

#53 seems to fix this issue for me using xcode8 GM

pachoo added a commit to pachoo/ideviceinstaller that referenced this issue Dec 2, 2016
…sues

Modified the define check to look for LIBZIP_VERSION as opposed to ZIP_CODEC_ENCODE.  libzip 0.10 introduced LIBZIP_VERSION (which is also used by all later versions) and also introduced the defines that the guard handles.  ZIP_CODEC_ENCODE is no longer used by later libzip versions (e.g. 1.12) which was causing compilation errors.

Also, the config.ac has a check that libzip is >= 0.10 so this is mostly a moot point.
@paulvojta
Copy link
Contributor

The problem is lines 56-58 of src/ideviceinstaller.c. As mentioned on line 55, they are for old versions of libzip -- versions prior to 0.10. The file uses the presence of ZIP_CODEC_ENCODE to distinguish libzip version 0.10 from earlier versions. The problem, though, is that ZIP_CODEC_ENCODE was moved to the (non-public) header file zipint.h sometime after version 0.11.2c. So, if a newer version of libzip is being used, lines 56-58 are used, and cause compilation errors.
In case you want to check on your own, here's the diff (in the libzip mercurial web access repository) where ZIP_CODEC_ENCODE was added: https://hg.nih.at/libzip/diff/2d8141cb2fa3/lib/zip.h (dated 14 Feb 2009), and here it was removed (actually moved to a non-public file): https://hg.nih.at/libzip/diff/1e4d47d717ef/lib/zip.h (dated 10 Oct 2014).
As was noted by pachoo in pull request #65, the configure script requires version 0.10 or higher of libzip, so lines 56-58 are moot at best, and cause compile errors at worst.
In an earlier comment I recommended replacing line 54, but I now believe that it's better to delete lines 54-60. See attached patch.
ideviceinstaller.c.pat.txt

paulvojta added a commit to paulvojta/ideviceinstaller that referenced this issue Nov 7, 2017
The reason for this is that these lines are only useful for very old versions
of libzip, but those versions are now disallowed by the configure script.

This fixes issues libimobiledevice#43, libimobiledevice#50, libimobiledevice#66, and (probably) libimobiledevice#55.
@tux-mind
Copy link

The problem is the #define zip_uint64_t off_t at the beginning as @paulvojta already figured out.
I would like to add that would be sufficient to check the libzip version according to zip_stat.
It should do those defines if zlib version is less than 0.10 and the target value is not off_t but int.

@paulvojta
Copy link
Contributor

Yes, but line 20 of configure.ac already requires libzip version 0.10 or higher: PKG_CHECK_MODULES(libzip, libzip >= 0.10)
So ideviceinstaller won't build with a lower version.
Also, note: libzip != zlib.

nikias pushed a commit that referenced this issue Mar 23, 2018
The reason for this is that these lines are only useful for very old versions
of libzip, but those versions are now disallowed by the configure script.

This fixes issues #43, #50, #66, and (probably) #55.
@nikias
Copy link
Member

nikias commented Mar 23, 2018

Fixed with #85

@nikias nikias closed this as completed Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants