From a4430ca9fd3e51a9484fe50188993b5621643ba1 Mon Sep 17 00:00:00 2001 From: inter515 Date: Sat, 29 Oct 2022 14:47:21 +0800 Subject: [PATCH] =?UTF-8?q?fixed=204c26ab3=20from=20https://gitee.com/inte?= =?UTF-8?q?r515/xts=5Facts=5Frelease/pulls/6239=20=E9=80=82=E9=85=8Dzlib?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: inter515 --- .../zlib/actszlibtest/ActsZlibTest.cpp | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/bundlemanager/zlib/actszlibtest/ActsZlibTest.cpp b/bundlemanager/zlib/actszlibtest/ActsZlibTest.cpp index 985927bb2..b79891308 100644 --- a/bundlemanager/zlib/actszlibtest/ActsZlibTest.cpp +++ b/bundlemanager/zlib/actszlibtest/ActsZlibTest.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "zlib.h" @@ -37,7 +38,7 @@ static int ONE = 1; static int FOUR = 4; static int SIX = 6; static int EIGHT = 8; -static int GARBAGE_LEN = strlen(GARBAGE); +static int GARBAGE_LEN = strlen(GARBAGE) + 1; static unsigned BUFFER_SIZE = 8192; std::mutex gzMutex_; std::mutex puMutex_; @@ -120,7 +121,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestCompress, Function | MediumTest | Level2) fprintf(stderr, "*********ActsZlibTestCompress Z_SOLO**********\n"); #else Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -172,7 +173,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestGzio, Function | MediumTest | Level2) ASSERT_TRUE(file != NULL); Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -204,7 +205,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestGzio, Function | MediumTest | Level2) HWTEST_F(ActsZlibTest, ActsZlibTestDeflate, Function | MediumTest | Level2) { Byte *compr; - uLong comprLen = 10000 * sizeof(int); + uLong comprLen = 100 * sizeof(int); compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); ASSERT_TRUE(compr != Z_NULL); @@ -252,7 +253,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestDeflate, Function | MediumTest | Level2) HWTEST_F(ActsZlibTest, ActsZlibTestInflate, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -294,7 +295,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestInflate, Function | MediumTest | Level2) HWTEST_F(ActsZlibTest, ActsZlibTestLargeDeflate, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -355,7 +356,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestLargeDeflate, Function | MediumTest | Level2) HWTEST_F(ActsZlibTest, ActsZlibTestLargeInflate, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -396,7 +397,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestLargeInflate, Function | MediumTest | Level2) HWTEST_F(ActsZlibTest, ActsZlibTestFlush, Function | MediumTest | Level2) { Byte *compr; - uLong comprLen = 10000 * sizeof(int); + uLong comprLen = 100 * sizeof(int); compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); ASSERT_TRUE(compr != Z_NULL); @@ -437,7 +438,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestFlush, Function | MediumTest | Level2) HWTEST_F(ActsZlibTest, ActsZlibTestSync, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -475,7 +476,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestSync, Function | MediumTest | Level2) HWTEST_F(ActsZlibTest, ActsZlibTestDictDeflate, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -514,7 +515,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestDictDeflate, Function | MediumTest | Level2) HWTEST_F(ActsZlibTest, ActsZlibTestDictInflate, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -570,7 +571,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestCompress2, Function | MediumTest | Level2) fprintf(stderr, "*********ActsZlibTestCompress2 Z_BEST_COMPRESSION Z_SOLO**********\n"); #else Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -634,7 +635,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestDeflateState, Function | MediumTest | Level2) { Byte *compr, *uncompr; int *bits = nullptr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -812,7 +813,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestGzBuffer, Function | MediumTest | Level2) int res = gzdirect(file); fprintf(stderr, "gzdirect result: %d\n", res); Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -960,7 +961,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestGzGets, Function | MediumTest | Level2) file = gzopen(TESTFILE, "wb"); ASSERT_TRUE(file != NULL); Byte *uncompr; - uLong uncomprLen = 10000 * sizeof(int); + uLong uncomprLen = 100 * sizeof(int); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); strcpy_s(reinterpret_cast(uncompr), GARBAGE_LEN, GARBAGE); fprintf(stderr, "gzgets\n"); @@ -1126,7 +1127,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestGzRead, Function | MediumTest | Level2) ASSERT_TRUE(file != NULL); Byte *uncompr; - uLong uncomprLen = 10000 * sizeof(int); + uLong uncomprLen = 100 * sizeof(int); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); ASSERT_TRUE(uncompr != Z_NULL); @@ -1310,7 +1311,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestGzInflateBack, Function | MediumTest | Level2 z_stream strm; unsigned char match[65280 + 2]; /* buffer for reversed match or gzip 32K sliding window */ Byte *uncompr; - uLong uncomprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong uncomprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); /* initialize inflateBack state for repeated use */ window = match; /* reuse match buffer */ @@ -1341,7 +1342,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestGzInflateBack, Function | MediumTest | Level2 HWTEST_F(ActsZlibTest, ActsZlibTestInflateCodesUsed, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -1385,7 +1386,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestInflateCopy_END, Function | MediumTest | Leve HWTEST_F(ActsZlibTest, ActsZlibTestInflateGetDictionary, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -1556,7 +1557,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestInflatePrime, Function | MediumTest | Level2) HWTEST_F(ActsZlibTest, ActsZlibTestInflateReset, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -1594,7 +1595,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestInflateReset, Function | MediumTest | Level2) HWTEST_F(ActsZlibTest, ActsZlibTestInflateSetDictionary, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -1628,7 +1629,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestInflateSetDictionary, Function | MediumTest | HWTEST_F(ActsZlibTest, ActsZlibTestInflateSyncPoint, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -1660,7 +1661,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestInflateSyncPoint, Function | MediumTest | Lev HWTEST_F(ActsZlibTest, ActsZlibTestInflateUndermine, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); @@ -1692,7 +1693,7 @@ HWTEST_F(ActsZlibTest, ActsZlibTestInflateUndermine, Function | MediumTest | Lev HWTEST_F(ActsZlibTest, ActsZlibTestInflateValidate, Function | MediumTest | Level2) { Byte *compr, *uncompr; - uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ + uLong comprLen = 100 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; compr = static_cast(calloc(static_cast(comprLen), CALLOC_SIZE)); uncompr = static_cast(calloc(static_cast(uncomprLen), CALLOC_SIZE)); -- GitLab