summaryrefslogtreecommitdiffstats
path: root/compat/zlib/gzlib.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-01-01 19:10:32 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-01-01 19:10:32 (GMT)
commitd2cdeda593457c08bfa561d317374933f9fcf925 (patch)
tree77c302923d88e96f0b6fbb399719fc25530be29c /compat/zlib/gzlib.c
parenta04ce08575e6013ffee3376c7d045a6709dee314 (diff)
downloadtcl-d2cdeda593457c08bfa561d317374933f9fcf925.zip
tcl-d2cdeda593457c08bfa561d317374933f9fcf925.tar.gz
tcl-d2cdeda593457c08bfa561d317374933f9fcf925.tar.bz2
Update zlib to version 1.2.9. Dll's and *.lib files not updated yet
Diffstat (limited to 'compat/zlib/gzlib.c')
-rw-r--r--compat/zlib/gzlib.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/compat/zlib/gzlib.c b/compat/zlib/gzlib.c
index fae202e..a87d3d1 100644
--- a/compat/zlib/gzlib.c
+++ b/compat/zlib/gzlib.c
@@ -1,11 +1,11 @@
/* gzlib.c -- zlib functions common to reading and writing gzip files
- * Copyright (C) 2004, 2010, 2011, 2012, 2013 Mark Adler
+ * Copyright (C) 2004, 2010, 2011, 2012, 2013, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "gzguts.h"
-#if defined(_WIN32) && !defined(__BORLANDC__)
+#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__)
# define LSEEK _lseeki64
#else
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
@@ -94,7 +94,7 @@ local gzFile gz_open(path, fd, mode)
const char *mode;
{
gz_statep state;
- size_t len;
+ z_size_t len;
int oflag;
#ifdef O_CLOEXEC
int cloexec = 0;
@@ -188,10 +188,10 @@ local gzFile gz_open(path, fd, mode)
}
/* save the path name for error messages */
-#ifdef _WIN32
+#ifdef WIDECHAR
if (fd == -2) {
len = wcstombs(NULL, path, 0);
- if (len == (size_t)-1)
+ if (len == (z_size_t)-1)
len = 0;
}
else
@@ -202,7 +202,7 @@ local gzFile gz_open(path, fd, mode)
free(state);
return NULL;
}
-#ifdef _WIN32
+#ifdef WIDECHAR
if (fd == -2)
if (len)
wcstombs(state->path, path, len + 1);
@@ -239,7 +239,7 @@ local gzFile gz_open(path, fd, mode)
/* open the file with the appropriate flags (or just use fd) */
state->fd = fd > -1 ? fd : (
-#ifdef _WIN32
+#ifdef WIDECHAR
fd == -2 ? _wopen(path, oflag, 0666) :
#endif
open((const char *)path, oflag, 0666));
@@ -248,8 +248,10 @@ local gzFile gz_open(path, fd, mode)
free(state);
return NULL;
}
- if (state->mode == GZ_APPEND)
+ if (state->mode == GZ_APPEND) {
+ LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */
state->mode = GZ_WRITE; /* simplify later checks */
+ }
/* save the current position for rewinding (only if reading) */
if (state->mode == GZ_READ) {
@@ -301,7 +303,7 @@ gzFile ZEXPORT gzdopen(fd, mode)
}
/* -- see zlib.h -- */
-#ifdef _WIN32
+#ifdef WIDECHAR
gzFile ZEXPORT gzopen_w(path, mode)
const wchar_t *path;
const char *mode;
@@ -329,6 +331,8 @@ int ZEXPORT gzbuffer(file, size)
return -1;
/* check and set requested size */
+ if ((size << 1) < size)
+ return -1; /* need to be able to double it */
if (size < 2)
size = 2; /* need two bytes to check magic header */
state->want = size;
@@ -611,7 +615,6 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
strcat(state->msg, ": ");
strcat(state->msg, msg);
#endif
- return;
}
#ifndef INT_MAX