fuzz: connman: cover AddLocalServices/RemoveLocalServices
What changed, and why it matters
This commit adds new test code to Bitcoin Core's fuzzing harness for the network connection manager. It exercises the AddLocalServices and RemoveLocalServices functions, which control what network service flags a node advertises. The change is purely a test/fuzzing addition and does not modify production code.
No action required. This is a benign test-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff extends the existing FUZZ_TARGET(connman) target in src/test/fuzz/connman.cpp with a new fuzz action that randomly adds or removes service flags, asserts the expected bit-manipulation behavior, and restores the original state. No production code is changed; no bug fix or behavior change is present.
Changed components
src/test/fuzz/connman.cppInspect captured patch +16 / −0
diff --git a/src/test/fuzz/connman.cpp b/src/test/fuzz/connman.cpp
index bf34538b..c2154ead 100644
--- a/src/test/fuzz/connman.cpp
+++ b/src/test/fuzz/connman.cpp
@@ -215,6 +215,22 @@ FUZZ_TARGET(connman, .init = initialize_connman)
[&] {
connman.SetTryNewOutboundPeer(fuzzed_data_provider.ConsumeBool());
},
+ [&] {
+ const auto services{ConsumeWeakEnum(fuzzed_data_provider, ALL_SERVICE_FLAGS)};
+ const auto before{connman.GetLocalServices()};
+ if (fuzzed_data_provider.ConsumeBool()) {
+ connman.AddLocalServices(services);
+ assert((connman.GetLocalServices() & services) == services);
+ // Restore by clearing only the bits that weren't already set.
+ connman.RemoveLocalServices(ServiceFlags(services & ~before));
+ } else {
+ connman.RemoveLocalServices(services);
+ assert((connman.GetLocalServices() & services) == 0);
+ // Restore by re-adding only the bits that were previously set.
+ connman.AddLocalServices(ServiceFlags(services & before));
+ }
+ assert(connman.GetLocalServices() == before);
+ },
[&] {
ConnectionType conn_type{
fuzzed_data_provider.PickValueInArray(ALL_CONNECTION_TYPES)};
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.