]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Avoid a conversion error in gzseek when off_t type too small.
authorMark Adler <madler@alumni.caltech.edu>
Sun, 5 Feb 2017 07:58:37 +0000 (23:58 -0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 15 Jan 2019 09:59:22 +0000 (10:59 +0100)
This is a problem in the odd case that the second argument of
LSEEK is a larger type than off_t. Apparently MinGW defines off_t
to be 32 bits, but _lseeki64 has a 64-bit second argument.

Also undo a previous commit to permit MinGW to use _lseeki64.

gzlib.c

diff --git a/gzlib.c b/gzlib.c
index 946fb2b4153f1573b47f398ded0a22ecdd27579c..dbf27aa43e391253039e42521da517f474968518 100644 (file)
--- a/gzlib.c
+++ b/gzlib.c
@@ -6,7 +6,7 @@
 #include "zbuild.h"
 #include "gzguts.h"
 
-#if defined(WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__)
+#if defined(WIN32) && !defined(__BORLANDC__)
 #  define LSEEK _lseeki64
 #else
 #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
@@ -312,7 +312,7 @@ z_off64_t ZEXPORT PREFIX(gzseek64)(gzFile file, z_off64_t offset, int whence) {
 
     /* if within raw area while reading, just go there */
     if (state->mode == GZ_READ && state->how == COPY && state->x.pos + offset >= 0) {
-        ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
+        ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR);
         if (ret == -1)
             return -1;
         state->x.have = 0;