From 1a3cfdf1b7ab2b55dbd0a4a4fa428b4e7d8bfa73 Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Wed, 29 Apr 2026 10:42:14 -0300 Subject: [PATCH] fuzz: connman: cover AddLocalServices/RemoveLocalServices --- src/test/fuzz/connman.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/fuzz/connman.cpp b/src/test/fuzz/connman.cpp index bf34538b3b9..c2154eade53 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)};