From: tb Date: Fri, 15 Mar 2024 21:32:21 +0000 (+0000) Subject: zlib: sync with upstream X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d62e7792cc782dbe996fdfa0cc89a6ba3ab562cd;p=openbsd zlib: sync with upstream More Windows #ifdef shuffling. Only one change relevant for OpenBSD: Make deflateBound() more conservative and handle Z_STREAM_END. --- diff --git a/lib/libz/deflate.c b/lib/libz/deflate.c index 623119b1fb2..7ab6c9942a6 100644 --- a/lib/libz/deflate.c +++ b/lib/libz/deflate.c @@ -842,13 +842,13 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) { storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) + (sourceLen >> 11) + 7; - /* if can't get parameters, return larger bound plus a zlib wrapper */ + /* if can't get parameters, return larger bound plus a wrapper */ if (deflateStateCheck(strm)) - return (fixedlen > storelen ? fixedlen : storelen) + 6; + return (fixedlen > storelen ? fixedlen : storelen) + 18; /* compute wrapper length */ s = strm->state; - switch (s->wrap) { + switch (s->wrap < 0 ? -s->wrap : s->wrap) { case 0: /* raw deflate */ wraplen = 0; break; @@ -878,7 +878,7 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) { break; #endif default: /* for compiler happiness */ - wraplen = 6; + wraplen = 18; } /* if not default parameters, return one of the conservative bounds */ diff --git a/lib/libz/gzguts.h b/lib/libz/gzguts.h index a6485ab7e9d..71dea740c65 100644 --- a/lib/libz/gzguts.h +++ b/lib/libz/gzguts.h @@ -17,11 +17,16 @@ # define ZLIB_INTERNAL #endif -#if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS) -# define _CRT_SECURE_NO_WARNINGS -#endif -#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE) -# define _CRT_NONSTDC_NO_DEPRECATE +#if defined(_WIN32) +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# ifndef _CRT_SECURE_NO_WARNINGS +# define _CRT_SECURE_NO_WARNINGS +# endif +# ifndef _CRT_NONSTDC_NO_DEPRECATE +# define _CRT_NONSTDC_NO_DEPRECATE +# endif #endif #include diff --git a/lib/libz/gzlib.c b/lib/libz/gzlib.c index e485a27bf6d..baa3e79d41a 100644 --- a/lib/libz/gzlib.c +++ b/lib/libz/gzlib.c @@ -5,11 +5,9 @@ #include "gzguts.h" -#if defined(UNDER_CE) -# define LSEEK _wcelseek -#elif defined(__DJGPP__) +#if defined(__DJGPP__) # define LSEEK llseek -#elif defined(_WIN32) && !defined(__BORLANDC__) +#elif defined(_WIN32) && !defined(__BORLANDC__) && !defined(UNDER_CE) # define LSEEK _lseeki64 #elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 # define LSEEK lseek64