From: Ilya Leoshkevich Date: Mon, 11 Oct 2021 11:47:20 +0000 (+0200) Subject: IBM Z: Do not check inflateGetDictionary() with DFLTCC X-Git-Tag: 2.1.0-beta1~503 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b4b8a7777b0bd7a18184cd3969683e40a395069;p=thirdparty%2Fzlib-ng.git IBM Z: Do not check inflateGetDictionary() with DFLTCC The zlib manual does not specify a strict contract for inflateGetDictionary(), it merely says that it "Returns the sliding dictionary being maintained by inflate", which is an implementation detail. IBM Z inflate's behavior differs from that of software, and may change in the future to boot. --- diff --git a/test/example.c b/test/example.c index 53abb5ee9..2a0332843 100644 --- a/test/example.c +++ b/test/example.c @@ -29,6 +29,9 @@ static const char hello[] = "hello, hello!"; static const char dictionary[] = "hello"; static unsigned long dictId = 0; /* Adler32 value of the dictionary */ +/* Maximum dictionary size, according to inflateGetDictionary() description. */ +#define MAX_DICTIONARY_SIZE 32768 + void test_compress (unsigned char *compr, z_size_t comprLen,unsigned char *uncompr, z_size_t uncomprLen); void test_gzio (const char *fname, unsigned char *uncompr, z_size_t uncomprLen); @@ -514,7 +517,7 @@ void test_dict_deflate(unsigned char *compr, size_t comprLen) { */ void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { int err; - uint8_t check_dictionary[10]; + uint8_t check_dictionary[MAX_DICTIONARY_SIZE]; uint32_t check_dictionary_len = 0; PREFIX3(stream) d_stream; /* decompression stream */ @@ -547,13 +550,17 @@ void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *unc err = PREFIX(inflateGetDictionary)(&d_stream, NULL, &check_dictionary_len); CHECK_ERR(err, "inflateGetDictionary"); +#ifndef S390_DFLTCC_INFLATE if (check_dictionary_len != sizeof(dictionary)) error("bad dictionary length\n"); +#endif err = PREFIX(inflateGetDictionary)(&d_stream, check_dictionary, &check_dictionary_len); CHECK_ERR(err, "inflateGetDictionary"); +#ifndef S390_DFLTCC_INFLATE if (memcmp(dictionary, check_dictionary, sizeof(dictionary)) != 0) error("bad dictionary\n"); +#endif err = PREFIX(inflateEnd)(&d_stream); CHECK_ERR(err, "inflateEnd");