Skip to content

Commit bf85c02

Browse files
fanquakevijaydasmp
authored andcommitted
Merge bitcoin#28931: fuzz: Limit fuzz buffer size in script_flags target
faf1fb2 Fix IWYU for the script_flags fuzz target (MarcoFalke) fa71285 fuzz: Limit fuzz buffer size in script_flags target (MarcoFalke) fa6b87b fuzz: CDataStream -> DataStream in script_flags (MarcoFalke) Pull request description: Most fuzz targets have an upper limit on the buffer size to avoid excessive runtime. Do the same for `script_flags` to avoid timeouts such as bitcoin#28812 (comment) Also, fix iwyu. Also, remove legacy `CDataStream`. ACKs for top commit: dergoegge: ACK faf1fb2 brunoerg: utACK faf1fb2 Tree-SHA512: 9301917b353f7409e448b6fd3635de19330856e0742431db5ef04e62873501b5b4cd6cb78ad81ada2747fa2bdae033115b5951d10489dd5d0d320426c8b96bee
1 parent ea0ef7c commit bf85c02

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/script/interpreter.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@
77
#define BITCOIN_SCRIPT_INTERPRETER_H
88

99
#include <script/script_error.h>
10+
#include <consensus/amount.h>
1011
#include <primitives/transaction.h>
12+
#include <script/script_error.h> // IWYU pragma: export
13+
#include <span.h>
14+
#include <uint256.h>
1115

16+
#include <cstddef>
17+
#include <cstdint>
1218
#include <vector>
13-
#include <stdint.h>
1419

1520
class CPubKey;
1621
class CScript;
17-
class CTransaction;
18-
class CTxOut;
19-
class uint256;
22+
class CScriptNum;
23+
class XOnlyPubKey;
2024

2125
/** Signature hash types/flags */
2226
enum

src/test/fuzz/script_flags.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,22 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <consensus/amount.h>
6-
#include <pubkey.h>
6+
#include <primitives/transaction.h>
77
#include <script/interpreter.h>
8+
#include <serialize.h>
89
#include <streams.h>
10+
#include <test/fuzz/fuzz.h>
911
#include <test/util/script.h>
10-
#include <version.h>
1112

12-
#include <test/fuzz/fuzz.h>
13+
#include <cassert>
14+
#include <ios>
15+
#include <utility>
16+
#include <vector>
1317

1418
FUZZ_TARGET(script_flags)
1519
{
16-
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
17-
try {
18-
int nVersion;
19-
ds >> nVersion;
20-
ds.SetVersion(nVersion);
21-
} catch (const std::ios_base::failure&) {
22-
return;
23-
}
24-
20+
if (buffer.size() > 100'000) return;
21+
DataStream ds{buffer};
2522
try {
2623
const CTransaction tx(deserialize, ds);
2724
const PrecomputedTransactionData txdata(tx);

0 commit comments

Comments
 (0)