From 055abe2fd3962ea0474ec552ff092e8aa050f3d4 Mon Sep 17 00:00:00 2001 From: div72 Date: Fri, 5 Apr 2024 00:08:34 +0300 Subject: [PATCH] rpc: check for return of LookupHost Not checking can cause a segfault if LookupHost fails. --- src/rpc/net.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 65180d6139..13127761d3 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -241,8 +241,9 @@ UniValue setban(const UniValue& params, bool fHelp) if (!isSubnet) { std::vector resolved; - LookupHost(params[0].get_str().c_str(), resolved, 1, false); - netAddr = resolved[0]; + if (LookupHost(params[0].get_str().c_str(), resolved, 1, false)) { + netAddr = resolved[0]; + } } else LookupSubNet(params[0].get_str().c_str(), subNet);