content_encoding: #error on too old zlib
The previous runtime check using strcmp() risks failing when zlib reaches 1.10. While this instead changes the logic to a cruder build-time instead of runtime, it avoids the 1.10 risk. I verified that ZLIB_VERNUM has been provided since at least the 1.2.0.3 release. 1.2.0.4 was released on 10 August 2003. Reported-by: Fay Stegerman Closes #16202
This commit is contained in:
parent
553248f501
commit
34acdf9986
@ -69,6 +69,10 @@
|
|||||||
|
|
||||||
#ifdef HAVE_LIBZ
|
#ifdef HAVE_LIBZ
|
||||||
|
|
||||||
|
#if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
|
||||||
|
#error "requires zlib 1.2.0.4 or newer"
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ZLIB_UNINIT, /* uninitialized */
|
ZLIB_UNINIT, /* uninitialized */
|
||||||
ZLIB_INIT, /* initialized */
|
ZLIB_INIT, /* initialized */
|
||||||
@ -309,24 +313,15 @@ static CURLcode gzip_do_init(struct Curl_easy *data,
|
|||||||
{
|
{
|
||||||
struct zlib_writer *zp = (struct zlib_writer *) writer;
|
struct zlib_writer *zp = (struct zlib_writer *) writer;
|
||||||
z_stream *z = &zp->z; /* zlib state structure */
|
z_stream *z = &zp->z; /* zlib state structure */
|
||||||
const char *v = zlibVersion();
|
|
||||||
|
|
||||||
/* Initialize zlib */
|
/* Initialize zlib */
|
||||||
z->zalloc = (alloc_func) zalloc_cb;
|
z->zalloc = (alloc_func) zalloc_cb;
|
||||||
z->zfree = (free_func) zfree_cb;
|
z->zfree = (free_func) zfree_cb;
|
||||||
|
|
||||||
if(strcmp(v, "1.2.0.4") >= 0) {
|
if(inflateInit2(z, MAX_WBITS + 32) != Z_OK)
|
||||||
/* zlib version >= 1.2.0.4 supports transparent gzip decompressing */
|
return process_zlib_error(data, z);
|
||||||
if(inflateInit2(z, MAX_WBITS + 32) != Z_OK) {
|
|
||||||
return process_zlib_error(data, z);
|
|
||||||
}
|
|
||||||
zp->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
failf(data, "too old zlib version: %s", v);
|
|
||||||
return CURLE_FAILED_INIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
zp->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user