From: Michihiro NAKAJIMA Date: Tue, 28 Jun 2011 05:20:00 +0000 (-0400) Subject: In the fuzz test, improve the calculation of damaging bytes so as to X-Git-Tag: v3.0.0a~256 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45717162189a88406efc8a286cbca7a3d1fd8144;p=thirdparty%2Flibarchive.git In the fuzz test, improve the calculation of damaging bytes so as to make at least one byte damage of the sample file even if its size is less than 100 bytes. SVN-Revision: 3440 --- diff --git a/libarchive/test/test_fuzz.c b/libarchive/test/test_fuzz.c index f810fbeb5..978898ee6 100644 --- a/libarchive/test/test_fuzz.c +++ b/libarchive/test/test_fuzz.c @@ -89,7 +89,7 @@ DEFINE_TEST(test_fuzz) struct archive *a; char *rawimage, *image; size_t size; - int i; + int i, q; extract_reference_file(filename); if (files[n].uncompress) { @@ -136,7 +136,9 @@ DEFINE_TEST(test_fuzz) /* Fuzz < 1% of the bytes in the archive. */ memcpy(image, rawimage, size); - numbytes = (int)(rand() % (size / 100)); + q = size / 100; + if (!q) q = 1; + numbytes = (int)(rand() % q); for (j = 0; j < numbytes; ++j) image[rand() % size] = (char)rand();