mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
fuzz: AutoFile with XOR
This commit is contained in:
parent
fab5cb9066
commit
faa25718b3
2 changed files with 11 additions and 5 deletions
|
|
@ -2,16 +2,16 @@
|
|||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <span.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
FUZZ_TARGET(autofile)
|
||||
|
|
@ -20,6 +20,7 @@ FUZZ_TARGET(autofile)
|
|||
FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
|
||||
AutoFile auto_file{
|
||||
fuzzed_file_provider.open(),
|
||||
ConsumeRandomLengthByteVector<std::byte>(fuzzed_data_provider),
|
||||
};
|
||||
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 100)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,16 +2,17 @@
|
|||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <span.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
FUZZ_TARGET(buffered_file)
|
||||
|
|
@ -19,7 +20,11 @@ FUZZ_TARGET(buffered_file)
|
|||
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
||||
FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
|
||||
std::optional<BufferedFile> opt_buffered_file;
|
||||
CAutoFile fuzzed_file{fuzzed_file_provider.open(), 0};
|
||||
CAutoFile fuzzed_file{
|
||||
fuzzed_file_provider.open(),
|
||||
0,
|
||||
ConsumeRandomLengthByteVector<std::byte>(fuzzed_data_provider),
|
||||
};
|
||||
try {
|
||||
opt_buffered_file.emplace(fuzzed_file, fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096), fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096));
|
||||
} catch (const std::ios_base::failure&) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue