fuzz: Avoid unsigned integer overflow in FormatParagraph
This commit is contained in:
2 files changed
+3
-1
No files matched your search
@@ -145,7 +145,8 @@ FUZZ_TARGET(string)
|
|||||||
(void)CopyrightHolders(random_string_1);
|
(void)CopyrightHolders(random_string_1);
|
||||||
FeeEstimateMode fee_estimate_mode;
|
FeeEstimateMode fee_estimate_mode;
|
||||||
(void)FeeModeFromString(random_string_1, fee_estimate_mode);
|
(void)FeeModeFromString(random_string_1, fee_estimate_mode);
|
||||||
(void)FormatParagraph(random_string_1, fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 1000), fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 1000));
|
const auto width{fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 1000)};
|
||||||
|
(void)FormatParagraph(random_string_1, width, fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, width));
|
||||||
(void)FormatSubVersion(random_string_1, fuzzed_data_provider.ConsumeIntegral<int>(), random_string_vector);
|
(void)FormatSubVersion(random_string_1, fuzzed_data_provider.ConsumeIntegral<int>(), random_string_vector);
|
||||||
(void)GetDescriptorChecksum(random_string_1);
|
(void)GetDescriptorChecksum(random_string_1);
|
||||||
(void)HelpExampleCli(random_string_1, random_string_2);
|
(void)HelpExampleCli(random_string_1, random_string_2);
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ bool ParseUInt64(const std::string& str, uint64_t* out)
|
|||||||
|
|
||||||
std::string FormatParagraph(const std::string& in, size_t width, size_t indent)
|
std::string FormatParagraph(const std::string& in, size_t width, size_t indent)
|
||||||
{
|
{
|
||||||
|
assert(width >= indent);
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
size_t ptr = 0;
|
size_t ptr = 0;
|
||||||
size_t indented = 0;
|
size_t indented = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user