3333
3434public class SnappyCombinedFuzzer {
3535
36+ @ FunctionalInterface
3637 private interface FuzzBlock {
3738 void run () throws Exception ;
3839 }
@@ -180,14 +181,15 @@ private static void testFramed(FuzzedDataProvider data) {
180181
181182 private static void testCrc32C (FuzzedDataProvider data ) {
182183 byte [] input = data .consumeBytes (data .consumeInt (0 , 4096 ));
183- byte [] chunk1 = data .consumeBytes (50 );
184- byte [] chunk2 = data .consumeBytes (50 );
185184
186185 PureJavaCrc32C crc = new PureJavaCrc32C ();
187186 crc .update (input , 0 , input .length );
188187 long value = crc .getValue ();
189188
190189 int intValue = crc .getIntegerValue ();
190+ if ((int ) value != intValue ) {
191+ throw new IllegalStateException ("CRC32C int value mismatch" );
192+ }
191193
192194 crc .reset ();
193195 crc .update (input , 0 , input .length );
@@ -200,42 +202,14 @@ private static void testCrc32C(FuzzedDataProvider data) {
200202 for (int i = 0 ; i < Math .min (input .length , 1000 ); i ++) {
201203 crcChunked .update (input [i ] & 0xFF );
202204 }
203- long chunkedValue = crcChunked .getValue ();
204205
205206 PureJavaCrc32C crcWhole = new PureJavaCrc32C ();
206207 crcWhole .update (input , 0 , input .length );
207208 long wholeValue = crcWhole .getValue ();
208209
209- if (input .length <= 1000 && chunkedValue != wholeValue ) {
210+ if (input .length <= 1000 && crcChunked . getValue () != wholeValue ) {
210211 throw new IllegalStateException ("CRC32C chunked vs whole mismatch" );
211212 }
212-
213- if (chunk1 .length > 0 && chunk2 .length > 0 ) {
214- PureJavaCrc32C crc1 = new PureJavaCrc32C ();
215- crc1 .update (input , 0 , input .length );
216- long crc1Value = crc1 .getValue ();
217-
218- PureJavaCrc32C crc2 = new PureJavaCrc32C ();
219- crc2 .update (chunk1 , 0 , chunk1 .length );
220- crc2 .update (chunk2 , 0 , chunk2 .length );
221- long crc2Value = crc2 .getValue ();
222- }
223-
224- PureJavaCrc32C crcEmpty = new PureJavaCrc32C ();
225- crcEmpty .update (new byte [0 ], 0 , 0 );
226- long emptyValue = crcEmpty .getValue ();
227-
228- if (input .length > 0 ) {
229- PureJavaCrc32C crcSingle = new PureJavaCrc32C ();
230- crcSingle .update (input [0 ] & 0xFF );
231- long singleValue = crcSingle .getValue ();
232- }
233-
234- if (input .length > 4 ) {
235- PureJavaCrc32C crcOffset = new PureJavaCrc32C ();
236- crcOffset .update (input , 1 , input .length - 1 );
237- long offsetValue = crcOffset .getValue ();
238- }
239213 }
240214
241215 private static void testBlockStream (FuzzedDataProvider data ) {
0 commit comments