upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/main.h
diff options
context:
space:
mode:
authormtg0001 <106211915+mtg0001@users.noreply.github.com>2026-07-31 16:05:35 -0300
committerGitHub <noreply@github.com>2026-07-31 16:05:35 -0300
commit59777ee34a5ab6297684b7ab8d5d93facd4ad6f3 (patch)
tree2a471982436dd64eec993ecaad97c7baeae1286a /src/main.h
parente2d5c1bbe01370dbf75e2118d697a159c4ee582b (diff)
net: bound what a peer can make the node allocate (#73)
Three independent bounds on what an untrusted peer can make this node allocate: - serialize.h: reject a compact size above MAX_SIZE before reading a string or a vector, instead of discovering it read by read. MAX_SIZE moves from main.h to serialize.h, where the checks live; headers_core.h includes serialize.h first, so every existing user still sees it. - main.cpp: cap an orphan transaction at 10,000 inputs. Orphans are stored and never validated, so mapOrphanTransactionsByPrev grew with one entry per input of every orphan a peer cared to send. - rpc.cpp: drop a Stratum line nested deeper than 20 before json::parse recurses into it. The scan tracks string state, so a worker name containing { or [ is no longer mistaken for nesting. Verified: builds clean on UCRT64; the depth scanner passes a table of legitimate Stratum lines and nesting attacks; a node built from this branch synced the chain from genesis to 4462 with no deserialization failure and no rejected block.
Diffstat (limited to 'src/main.h')
-rw-r--r--src/main.h1
1 files changed, 0 insertions, 1 deletions
diff --git a/src/main.h b/src/main.h
index 3bc1219..7266e3d 100644
--- a/src/main.h
+++ b/src/main.h
@@ -14,7 +14,6 @@ class CBlockIndex;
14class CWalletTx; 14class CWalletTx;
15class CKeyItem; 15class CKeyItem;
16 16
17static const unsigned int MAX_SIZE = 0x02000000;
18// Ceiling on transactions held waiting for a parent that has not arrived. 17// Ceiling on transactions held waiting for a parent that has not arrived.
19// They cost a peer nothing to send and are never validated, only stored. 18// They cost a peer nothing to send and are never validated, only stored.
20static const unsigned int MAX_ORPHAN_TRANSACTIONS = 100; 19static const unsigned int MAX_ORPHAN_TRANSACTIONS = 100;