diff options
| author | Mark Adler <git@madler.net> | 2026-01-03 01:07:40 -0600 |
|---|---|---|
| committer | Mark Adler <git@madler.net> | 2026-01-05 15:03:04 -0600 |
| commit | fd366384cf324d750596feb03be44ddf4d1e6acd (patch) | |
| tree | 0c1d8eaa0538f8681ae0ce7a4e02ba71ff07d4fd /zutil.c | |
| parent | cab7352dc71048f130a7d4e0b7fd773909761133 (diff) | |
| download | zlib-fd366384cf324d750596feb03be44ddf4d1e6acd.tar.gz zlib-fd366384cf324d750596feb03be44ddf4d1e6acd.tar.bz2 zlib-fd366384cf324d750596feb03be44ddf4d1e6acd.zip | |
Prevent the use of insecure functions without an explicit request.
ZLIB_INSECURE must be defined in order to compile code that uses
the insecure functions vsprintf() or sprintf(). This would occur
only if the standard vsnprintf() or snprintf() functions are not
available. Providing the --insecure option to ./configure will
define ZLIB_INSECURE. A flag is added to zlibCompileFlags() to
indicate that gzprintf() is not implemented due to the need for
the use of an insecure function, but ZLIB_INSECURE was not
defined.
Diffstat (limited to 'zutil.c')
| -rw-r--r-- | zutil.c | 48 |
1 files changed, 28 insertions, 20 deletions
| @@ -86,28 +86,36 @@ uLong ZEXPORT zlibCompileFlags(void) { | |||
| 86 | flags += 1L << 21; | 86 | flags += 1L << 21; |
| 87 | #endif | 87 | #endif |
| 88 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) | 88 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) |
| 89 | # ifdef NO_vsnprintf | 89 | # ifdef NO_vsnprintf |
| 90 | flags += 1L << 25; | 90 | # ifdef ZLIB_INSECURE |
| 91 | # ifdef HAS_vsprintf_void | 91 | flags += 1L << 25; |
| 92 | flags += 1L << 26; | 92 | # else |
| 93 | # endif | 93 | flags += 1L << 27; |
| 94 | # else | 94 | # endif |
| 95 | # ifdef HAS_vsnprintf_void | 95 | # ifdef HAS_vsprintf_void |
| 96 | flags += 1L << 26; | 96 | flags += 1L << 26; |
| 97 | # endif | 97 | # endif |
| 98 | # endif | 98 | # else |
| 99 | # ifdef HAS_vsnprintf_void | ||
| 100 | flags += 1L << 26; | ||
| 101 | # endif | ||
| 102 | # endif | ||
| 99 | #else | 103 | #else |
| 100 | flags += 1L << 24; | 104 | flags += 1L << 24; |
| 101 | # ifdef NO_snprintf | 105 | # ifdef NO_snprintf |
| 102 | flags += 1L << 25; | 106 | # ifdef ZLIB_INSECURE |
| 103 | # ifdef HAS_sprintf_void | 107 | flags += 1L << 25; |
| 104 | flags += 1L << 26; | 108 | # else |
| 105 | # endif | 109 | flags += 1L << 27; |
| 106 | # else | 110 | # endif |
| 107 | # ifdef HAS_snprintf_void | 111 | # ifdef HAS_sprintf_void |
| 108 | flags += 1L << 26; | 112 | flags += 1L << 26; |
| 109 | # endif | 113 | # endif |
| 110 | # endif | 114 | # else |
| 115 | # ifdef HAS_snprintf_void | ||
| 116 | flags += 1L << 26; | ||
| 117 | # endif | ||
| 118 | # endif | ||
| 111 | #endif | 119 | #endif |
| 112 | return flags; | 120 | return flags; |
| 113 | } | 121 | } |
