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
diff --git a/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp b/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp
index b6fbc14..a15bc89 100644
--- a/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp
+++ b/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp
@@ -198,13 +198,13 @@
[&]() {
uint32_t groupVectorSize = metadata->groups.size();
uint32_t randomGroupIndex =
- mFdp.ConsumeIntegralInRange<uint32_t>(0, groupVectorSize);
+ mFdp.ConsumeIntegralInRange<uint32_t>(0, groupVectorSize - 1);
GetPartitionGroupName(metadata->groups[randomGroupIndex]);
},
[&]() {
uint32_t blockDeviceVectorSize = metadata->block_devices.size();
uint32_t randomBlockDeviceIndex =
- mFdp.ConsumeIntegralInRange<uint32_t>(0, blockDeviceVectorSize);
+ mFdp.ConsumeIntegralInRange<uint32_t>(0, blockDeviceVectorSize - 1);
GetBlockDevicePartitionName(
metadata->block_devices[randomBlockDeviceIndex]);
},
@@ -224,7 +224,7 @@
[&]() {
uint32_t partitionVectorSize = metadata->partitions.size();
uint32_t randomPartitionIndex =
- mFdp.ConsumeIntegralInRange<uint32_t>(0, partitionVectorSize);
+ mFdp.ConsumeIntegralInRange<uint32_t>(0, partitionVectorSize - 1);
GetPartitionName(metadata->partitions[randomPartitionIndex]);
},
[&]() { GetTotalSuperPartitionSize(metadataValue); },