File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,22 @@ template <typename WeakEnumType, size_t size>
180180 return UintToArith256 (ConsumeUInt256 (fuzzed_data_provider));
181181}
182182
183+ [[nodiscard]] inline arith_uint256 ConsumeArithUInt256InRange (FuzzedDataProvider& fuzzed_data_provider, const arith_uint256& min, const arith_uint256& max) noexcept
184+ {
185+ assert (min <= max);
186+ const arith_uint256 range = max - min;
187+ const arith_uint256 value = ConsumeArithUInt256 (fuzzed_data_provider);
188+ arith_uint256 result = value;
189+ // Avoid division by 0, in case range + 1 results in overflow.
190+ if (range != ~arith_uint256 (0 )) {
191+ const arith_uint256 quotient = value / (range + 1 );
192+ result = value - (quotient * (range + 1 ));
193+ }
194+ result += min;
195+ assert (result >= min && result <= max);
196+ return result;
197+ }
198+
183199[[nodiscard]] std::map<COutPoint, Coin> ConsumeCoins (FuzzedDataProvider& fuzzed_data_provider) noexcept ;
184200
185201[[nodiscard]] CTxDestination ConsumeTxDestination (FuzzedDataProvider& fuzzed_data_provider) noexcept ;
You can’t perform that action at this time.
0 commit comments