]> granicus.if.org Git - zziplib/commitdiff
zzip: fseeko: fix comparison between incompatible pointer types
authorPatrick Steinhardt <ps@pks.im>
Tue, 21 May 2019 11:24:29 +0000 (13:24 +0200)
committerPatrick Steinhardt <ps@pks.im>
Thu, 1 Aug 2019 06:33:34 +0000 (08:33 +0200)
The C standard does not allow for comparing incompatible pointer types
with each other. This causes the C compiler to emit a warning when we
try to compare a pointer of type `struct zzip_disk64_trailer` (cast to
`void *`) with a pointer of type `unsigned char`.

Fix this by comparing `p + sizeof(trailer)` with `buffer + mapsize`
instead of using the cast struct.

zzip/fseeko.c

index 50d4a957382b962c2712b438f314ac3e663bc9a5..f89569060a6c547d5c412f35086c2bc88c550610 100644 (file)
@@ -387,7 +387,7 @@ zzip_entry_findfirst(FILE * disk)
                     errno = EFBIG;
                     goto error2;
                 }
-                if ((void*)(trailer + 1) > (buffer + mapsize))
+                if ((p + sizeof(*trailer)) > (buffer + mapsize))
                 {
                     debug1("disk64 trailer is not complete");
                     errno = EBADMSG;