solang-0001: add_external_functions emits_events Vec::contains O(F×E²) MEDIUM src/sema/external_functions.rs:93-103 — dedup accumulator Vec uses linear scan for each event per function; fix: IndexSet (already a dependency) for O(1) dedup tor/bitcoin/transmission/libtorrent/solc: CLEAN markers added after full scan Tor: nodes_have_common_family_id F=1-3 IDs, O(N×F²) ≈ O(9N), not scalable issue Bitcoin: TxGraph/sets throughout, no linear scan in hot paths Transmission: bitfields for piece tracking, sorted binary search for string table libtorrent: sorted vectors with lower_bound, DHT uses binary search on results solc: unordered_set/set throughout OverrideChecker, SMTEncoder, FunctionCallGraph
1.4 KiB
1.4 KiB
CLEAN — Bitcoin Core
Scanned 2026-03-29 for CWE-407 (algorithmic complexity: O(N²) linear membership tests, O(2^D) diamond recursion).
Scope
src/txmempool.cpp/src/txmempool.h— mempool ancestor/descendant trackingsrc/node/mini_miner.cpp— MiniMiner block template buildersrc/policy/packages.cpp— package deduplicationsrc/net.cpp— peer connection tracking
Findings
- Mempool ancestor/descendant tracking — uses
CTxGraph::GetAncestors/GetDescendantsbacked bystd::setand hash maps (O(log N) per lookup). CLEAN. MiniMiner::DeleteAncestorPackage—std::findonm_entriesvector to locate an ancestor before erase.m_entriesis a sorted vector used purely for O(N log N) re-sort each iteration; the O(|ancestors|) find per removal is dominated by the O(E log E) sort already on that path.m_entries_by_txid(hash map) handles fast txid lookup. Effective complexity is O(E log E) per iteration. Not a scalable O(N²). CLEAN.policy/packages.cpp— usesstd::unordered_set<COutPoint>for input dedup. CLEAN.net.cppm_onion_binds— constant-size list (number of configured bind addresses). CLEAN.- Address management — uses bucket-based hash tables throughout. CLEAN.
Result: No actionable CWE-407 defects. Bitcoin Core uses hash-based sets and sorted structures for all scalable membership tests.