#217 ✓resolved
wizzrobe

warning in ideviceinstaller.c

Reported by wizzrobe | May 18th, 2011 @ 09:19 PM

Just cloned the latest ideviceinstaller git and built on arch linux, using gcc version 4.6.0 20110513 and libzip 0.10

Line 166 in ideviceinstaller.c gives the following warning:
error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]

Turns out zip_fread returns signed int64 while zip_stat size is an unsigned int64.

I was able to fix with the following patch that tries to do a safe cast. Hopefully it is at least helpful:

--- a/src/ideviceinstaller.c
+++ b/src/ideviceinstaller.c
@@ -163,7 +163,7 @@ static int zip_f_get_contents(struct zip *zf, const char *filename, int locate_f

        }
 
        *buffer = malloc(zs.size);
-       if (zip_fread(zfile, *buffer, zs.size) != zs.size) {
+       if (zs.size>LLONG_MAX || zip_fread(zfile, *buffer, zs.size) != (zip_int64_t)zs.size) {
                fprintf(stderr, "ERROR: zip_fread %" PRIu64 " bytes from '%s'\n", (uint64_t)zs.size, filename);
                free(*buffer);
                *buffer = NULL;

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

A project around supporting the iPhone in Linux.

See http://libimobiledevice.org

People watching this ticket

Pages