]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fixed : decoder error on erroneous data
authorYann Collet <yann.collet.73@gmail.com>
Sat, 19 Mar 2016 10:40:19 +0000 (11:40 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Sat, 19 Mar 2016 10:40:19 +0000 (11:40 +0100)
programs/fuzzer.c

index 55e0c7d70dbe5d55f1b6ac2444fdda3bc4bd3aef..72d71ea987dba02312135bcfb6052f9ac2e1842b 100644 (file)
@@ -596,18 +596,16 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit
             }
 
             /* decompress noisy source */
-            {
-                U32 noiseSrc = FUZ_rand(&lseed) % 5;
-                const U32 endMark = 0xA9B1C3D6;
-                U32 endCheck;
+            {   U32 const noiseSrc = FUZ_rand(&lseed) % 5;
+                U32 const endMark = 0xA9B1C3D6;
                 srcBuffer = cNoiseBuffer[noiseSrc];
                 memcpy(dstBuffer+sampleSize, &endMark, 4);
                 errorCode = ZSTD_decompress(dstBuffer, sampleSize, cBuffer, cSize);
                 /* result *may* be an unlikely success, but even then, it must strictly respect dest buffer boundaries */
                 CHECK((!ZSTD_isError(errorCode)) && (errorCode>sampleSize),
                       "ZSTD_decompress on noisy src : result is too large : %u > %u (dst buffer)", (U32)errorCode, (U32)sampleSize);
-                memcpy(&endCheck, dstBuffer+sampleSize, 4);
-                CHECK(endMark!=endCheck, "ZSTD_decompress on noisy src : dst buffer overflow");
+                { U32 endCheck; memcpy(&endCheck, dstBuffer+sampleSize, 4);
+                CHECK(endMark!=endCheck, "ZSTD_decompress on noisy src : dst buffer overflow"); }
             }
         }