binder_rpc_fuzzer: limit connections
Unbounded connections will exhaust resources.
Fixes: 260736889
Test: w/ reproducer
Change-Id: Ic21a1b4aab1127fbf4b9d3d943d0b27f423b84ea
diff --git a/libs/binder/tests/rpc_fuzzer/main.cpp b/libs/binder/tests/rpc_fuzzer/main.cpp
index f68a561..b8ae84d 100644
--- a/libs/binder/tests/rpc_fuzzer/main.cpp
+++ b/libs/binder/tests/rpc_fuzzer/main.cpp
@@ -133,8 +133,13 @@
bool hangupBeforeShutdown = provider.ConsumeBool();
+ // b/260736889 - limit arbitrarily, due to thread resource exhaustion, which currently
+ // aborts. Servers should consider RpcServer::setConnectionFilter instead.
+ constexpr size_t kMaxConnections = 1000;
+
while (provider.remaining_bytes() > 0) {
- if (connections.empty() || provider.ConsumeBool()) {
+ if (connections.empty() ||
+ (connections.size() < kMaxConnections && provider.ConsumeBool())) {
base::unique_fd fd(TEMP_FAILURE_RETRY(socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)));
CHECK_NE(fd.get(), -1);
CHECK_EQ(0,