Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2020-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <test/fuzz/FuzzedDataProvider.h>6#include <test/fuzz/fuzz.h>7#include <test/fuzz/util.h>8#include <test/util/setup_common.h>9#include <torcontrol.h>11#include <cstdint>12#include <string>13#include <vector>15void initialize_torcontrol()16{17static const auto testing_setup = MakeNoLogFileContext<>();18}20FUZZ_TARGET(torcontrol, .init = initialize_torcontrol)21{22FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};24TorController tor_controller;25CThreadInterrupt interrupt;26TorControlConnection conn{interrupt};28LIMITED_WHILE (fuzzed_data_provider.ConsumeBool(), 10000) {29TorControlReply tor_control_reply;30CallOneOf(31fuzzed_data_provider,32[&] {33tor_control_reply.code = TOR_REPLY_OK;34},35[&] {36tor_control_reply.code = TOR_REPLY_UNRECOGNIZED;37},38[&] {39tor_control_reply.code = TOR_REPLY_SYNTAX_ERROR;40},41[&] {42tor_control_reply.code = fuzzed_data_provider.ConsumeIntegral<int>();43});44tor_control_reply.lines = ConsumeRandomLengthStringVector(fuzzed_data_provider);46CallOneOf(47fuzzed_data_provider,48[&] {49tor_controller.add_onion_cb(conn, tor_control_reply, /*pow_was_enabled=*/true);50},51[&] {52tor_controller.add_onion_cb(conn, tor_control_reply, /*pow_was_enabled=*/false);53},54[&] {55tor_controller.auth_cb(conn, tor_control_reply);56},57[&] {58tor_controller.authchallenge_cb(conn, tor_control_reply);59},60[&] {61tor_controller.protocolinfo_cb(conn, tor_control_reply);62},63[&] {64tor_controller.get_socks_cb(conn, tor_control_reply);65});66}67}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.