From 93b6efcb2f969c6de0fd1eca5b07dbce18046c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= Date: Sat, 15 Jun 2019 06:53:27 +0200 Subject: [PATCH] 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 -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]