From 14e997fe433237011f9ab3c82f3c7f896e83c1e0 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Tue, 24 Oct 2023 14:38:49 -0700 Subject: [PATCH] Fix indices in fuzzer. There are a few places where an index is randomly generated, but the max is incorrectly set to the size of the value not one less than the size. All of these occurrences have been fixed. Bug: 306230574 Test: Ran fuzzer instance that failed, no longer fails. Change-Id: I20dfbc19a0df9cb160f8c861e072f083e24a4fab --- fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp b/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp index b6fbc142a..a15bc8905 100644 --- a/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp +++ b/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp @@ -198,13 +198,13 @@ void LiplpApisFuzzer::process() { [&]() { uint32_t groupVectorSize = metadata->groups.size(); uint32_t randomGroupIndex = - mFdp.ConsumeIntegralInRange(0, groupVectorSize); + mFdp.ConsumeIntegralInRange(0, groupVectorSize - 1); GetPartitionGroupName(metadata->groups[randomGroupIndex]); }, [&]() { uint32_t blockDeviceVectorSize = metadata->block_devices.size(); uint32_t randomBlockDeviceIndex = - mFdp.ConsumeIntegralInRange(0, blockDeviceVectorSize); + mFdp.ConsumeIntegralInRange(0, blockDeviceVectorSize - 1); GetBlockDevicePartitionName( metadata->block_devices[randomBlockDeviceIndex]); }, @@ -224,7 +224,7 @@ void LiplpApisFuzzer::process() { [&]() { uint32_t partitionVectorSize = metadata->partitions.size(); uint32_t randomPartitionIndex = - mFdp.ConsumeIntegralInRange(0, partitionVectorSize); + mFdp.ConsumeIntegralInRange(0, partitionVectorSize - 1); GetPartitionName(metadata->partitions[randomPartitionIndex]); }, [&]() { GetTotalSuperPartitionSize(metadataValue); },