Blob Blame History Raw
From de0ce0ea50b5925572da2aee65a3c39cae7a5ea4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
Date: Sun, 9 Jun 2019 21:07:33 +0200
Subject: [PATCH 1/2] util/zlib/deflater: Fix several compiler warnings.

---
 util/zlib/deflater.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/util/zlib/deflater.c b/util/zlib/deflater.c
index 32d01a36e..7e13600ad 100644
--- a/util/zlib/deflater.c
+++ b/util/zlib/deflater.c
@@ -16,8 +16,8 @@
 int main(int argc, char* argv[])
 {
         FILE* fp;
-        char* inbuf;
-        char* outbuf;
+        unsigned char* inbuf;
+        unsigned char* outbuf;
         size_t inlen;
         size_t outlen;
         z_stream stream;
@@ -84,7 +84,7 @@ int main(int argc, char* argv[])
         }
 
         /* display summary */
-        printf("Compressed %s (%d bytes) to %s (%d bytes)\n",
+        printf("Compressed %s (%zu bytes) to %s (%zu bytes)\n",
                 argv[1], inlen, argv[2], outlen);
         return 0;
 }

From a30091a3400daa9f1a8ba503e735f52a1e6d775a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
Date: Sat, 15 Jun 2019 06:53:27 +0200
Subject: [PATCH 2/2] zlib: Use correct (un)signedness of char in prototypes
 and functions.

Also ensure we are using the same constness qualifiers.
---
 include/zlib.h           | 7 ++++---
 libsrc/zlib/inflatemem.s | 3 ++-
 libsrc/zlib/uncompress.c | 9 ++++-----
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/include/zlib.h b/include/zlib.h
index 8ced89800..3f6c2b27b 100644
--- a/include/zlib.h
+++ b/include/zlib.h
@@ -48,7 +48,8 @@
 #define Z_NULL       0
 
 
-unsigned __fastcall__ inflatemem (char* dest, const char* source);
+unsigned __fastcall__ inflatemem (unsigned char* dest,
+                                  const unsigned char* source);
 /*
      Decompresses the source buffer into the destination buffer.
    Returns the size of the uncompressed data (number of bytes written starting
@@ -83,8 +84,8 @@ unsigned __fastcall__ inflatemem (char* dest, const char* source);
 */
 
 
-int __fastcall__ uncompress (char* dest, unsigned* destLen,
-                             const char* source, unsigned sourceLen);
+int __fastcall__ uncompress (unsigned char* dest, unsigned* destLen,
+                             const unsigned char* source, unsigned sourceLen);
 /*
    Original zlib description:
 
diff --git a/libsrc/zlib/inflatemem.s b/libsrc/zlib/inflatemem.s
index bc89f2016..80c19f223 100644
--- a/libsrc/zlib/inflatemem.s
+++ b/libsrc/zlib/inflatemem.s
@@ -1,7 +1,8 @@
 ;
 ; 2017-11-07, Piotr Fusik
 ;
-; unsigned __fastcall__ inflatemem (char* dest, const char* source);
+; unsigned __fastcall__ inflatemem (unsigned char* dest,
+;                                   const unsigned char* source);
 ;
 ; NOTE: Be extremely careful with modifications, because this code is heavily
 ; optimized for size (for example assumes certain register and flag values
diff --git a/libsrc/zlib/uncompress.c b/libsrc/zlib/uncompress.c
index 4e449a3ef..61838b47d 100644
--- a/libsrc/zlib/uncompress.c
+++ b/libsrc/zlib/uncompress.c
@@ -6,11 +6,11 @@
 
 #include <zlib.h>
 
-int __fastcall__ uncompress (char* dest, unsigned* destLen,
-                             const char* source, unsigned sourceLen)
+int __fastcall__ uncompress (unsigned char* dest, unsigned* destLen,
+                             const unsigned char* source, unsigned sourceLen)
 {
         unsigned len;
-        unsigned char* ptr;
+        const unsigned char* ptr = source + sourceLen - 4;
         unsigned long csum;
         /* source[0]: Compression method and flags
             bits 0 to 3: Compression method (must be Z_DEFLATED)
@@ -22,10 +22,9 @@ int __fastcall__ uncompress (char* dest, unsigned* destLen,
         */
         if ((source[0] & 0x8f) != Z_DEFLATED || source[1] & 0x20)
                 return Z_DATA_ERROR;
-        if ((((unsigned) source[0] << 8) | (unsigned char) source[1]) % 31)
+        if ((((unsigned) source[0] << 8) | source[1]) % 31)
                 return Z_DATA_ERROR;
         *destLen = len = inflatemem(dest, source + 2);
-        ptr = (unsigned char*) source + sourceLen - 4;
         csum = adler32(adler32(0L, Z_NULL, 0), dest, len);
         if ((unsigned char) csum != ptr[3]
          || (unsigned char) (csum >> 8) != ptr[2]