Skip to content

Commit 1ae46dc

Browse files
committed
Merge #17754: net: Don't allow resolving of std::string with embedded NUL characters. Add tests.
7a046cd tests: Avoid using C-style NUL-terminated strings as arguments (practicalswift) fefb916 tests: Add tests to make sure lookup methods fail on std::string parameters with embedded NUL characters (practicalswift) 9574de8 net: Avoid using C-style NUL-terminated strings as arguments in the netbase interface (practicalswift) Pull request description: Don't allow resolving of `std::string`:s with embedded `NUL` characters. Avoid using C-style `NUL`-terminated strings as arguments in the `netbase` interface Add tests. The only place in where C-style `NUL`-terminated strings are actually needed is here: ```diff + if (!ValidAsCString(name)) { + return false; + } ... - int nErr = getaddrinfo(pszName, nullptr, &aiHint, &aiRes); + int nErr = getaddrinfo(name.c_str(), nullptr, &aiHint, &aiRes); if (nErr) return false; ``` Interface changes: ```diff -bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup); +bool LookupHost(const std::string& name, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup); -bool LookupHost(const char *pszName, CNetAddr& addr, bool fAllowLookup); +bool LookupHost(const std::string& name, CNetAddr& addr, bool fAllowLookup); -bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLookup); +bool Lookup(const std::string& name, CService& addr, int portDefault, bool fAllowLookup); -bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions); +bool Lookup(const std::string& name, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions); -bool LookupSubNet(const char *pszName, CSubNet& subnet); +bool LookupSubNet(const std::string& strSubnet, CSubNet& subnet); -CService LookupNumeric(const char *pszName, int portDefault = 0); +CService LookupNumeric(const std::string& name, int portDefault = 0); -bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, const SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed); +bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, const SOCKET& hSocketRet, int nTimeout, bool& outProxyConnectionFailed); ``` It should be noted that the `ConnectThroughProxy` change (from `bool *outProxyConnectionFailed` to `bool& outProxyConnectionFailed`) has nothing to do with `NUL` handling but I thought it was worth doing when touching this file :) ACKs for top commit: EthanHeilman: ACK 7a046cd laanwj: ACK 7a046cd Tree-SHA512: 66556e290db996917b54091acd591df221f72230f6b9f6b167b9195ee870ebef6e26f4cda2f6f54d00e1c362e1743bf56785d0de7cae854e6bf7d26f6caccaba
2 parents 04f78b8 + 7a046cd commit 1ae46dc

13 files changed

+99
-69
lines changed

src/httpserver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static bool InitHTTPAllowList()
172172
rpc_allow_subnets.push_back(CSubNet(localv6)); // always allow IPv6 localhost
173173
for (const std::string& strAllow : gArgs.GetArgs("-rpcallowip")) {
174174
CSubNet subnet;
175-
LookupSubNet(strAllow.c_str(), subnet);
175+
LookupSubNet(strAllow, subnet);
176176
if (!subnet.IsValid()) {
177177
uiInterface.ThreadSafeMessageBox(
178178
strprintf("Invalid -rpcallowip subnet specification: %s. Valid are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24).", strAllow),
@@ -324,7 +324,7 @@ static bool HTTPBindAddresses(struct evhttp* http)
324324
evhttp_bound_socket *bind_handle = evhttp_bind_socket_with_handle(http, i->first.empty() ? nullptr : i->first.c_str(), i->second);
325325
if (bind_handle) {
326326
CNetAddr addr;
327-
if (i->first.empty() || (LookupHost(i->first.c_str(), addr, false) && addr.IsBindAny())) {
327+
if (i->first.empty() || (LookupHost(i->first, addr, false) && addr.IsBindAny())) {
328328
LogPrintf("WARNING: the RPC server is not safe to expose to untrusted networks such as the public internet\n");
329329
}
330330
boundSockets.push_back(bind_handle);

src/init.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ bool AppInitMain(NodeContext& node)
13581358
SetReachable(NET_ONION, false);
13591359
if (proxyArg != "" && proxyArg != "0") {
13601360
CService proxyAddr;
1361-
if (!Lookup(proxyArg.c_str(), proxyAddr, 9050, fNameLookup)) {
1361+
if (!Lookup(proxyArg, proxyAddr, 9050, fNameLookup)) {
13621362
return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'").translated, proxyArg));
13631363
}
13641364

@@ -1382,7 +1382,7 @@ bool AppInitMain(NodeContext& node)
13821382
SetReachable(NET_ONION, false);
13831383
} else {
13841384
CService onionProxy;
1385-
if (!Lookup(onionArg.c_str(), onionProxy, 9050, fNameLookup)) {
1385+
if (!Lookup(onionArg, onionProxy, 9050, fNameLookup)) {
13861386
return InitError(strprintf(_("Invalid -onion address or hostname: '%s'").translated, onionArg));
13871387
}
13881388
proxyType addrOnion = proxyType(onionProxy, proxyRandomize);
@@ -1400,7 +1400,7 @@ bool AppInitMain(NodeContext& node)
14001400

14011401
for (const std::string& strAddr : gArgs.GetArgs("-externalip")) {
14021402
CService addrLocal;
1403-
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
1403+
if (Lookup(strAddr, addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
14041404
AddLocal(addrLocal, LOCAL_MANUAL);
14051405
else
14061406
return InitError(ResolveErrMsg("externalip", strAddr));
@@ -1780,7 +1780,7 @@ bool AppInitMain(NodeContext& node)
17801780

17811781
for (const std::string& strBind : gArgs.GetArgs("-bind")) {
17821782
CService addrBind;
1783-
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) {
1783+
if (!Lookup(strBind, addrBind, GetListenPort(), false)) {
17841784
return InitError(ResolveErrMsg("bind", strBind));
17851785
}
17861786
connOptions.vBinds.push_back(addrBind);

src/net.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
410410
if (hSocket == INVALID_SOCKET) {
411411
return nullptr;
412412
}
413-
connected = ConnectThroughProxy(proxy, addrConnect.ToStringIP(), addrConnect.GetPort(), hSocket, nConnectTimeout, &proxyConnectionFailed);
413+
connected = ConnectThroughProxy(proxy, addrConnect.ToStringIP(), addrConnect.GetPort(), hSocket, nConnectTimeout, proxyConnectionFailed);
414414
} else {
415415
// no proxy needed (none set for target network)
416416
hSocket = CreateSocket(addrConnect);
@@ -432,7 +432,8 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
432432
std::string host;
433433
int port = default_port;
434434
SplitHostPort(std::string(pszDest), port, host);
435-
connected = ConnectThroughProxy(proxy, host, port, hSocket, nConnectTimeout, nullptr);
435+
bool proxyConnectionFailed;
436+
connected = ConnectThroughProxy(proxy, host, port, hSocket, nConnectTimeout, proxyConnectionFailed);
436437
}
437438
if (!connected) {
438439
CloseSocket(hSocket);
@@ -1609,7 +1610,7 @@ void CConnman::ThreadDNSAddressSeed()
16091610
continue;
16101611
}
16111612
unsigned int nMaxIPs = 256; // Limits number of IPs learned from a DNS seed
1612-
if (LookupHost(host.c_str(), vIPs, nMaxIPs, true)) {
1613+
if (LookupHost(host, vIPs, nMaxIPs, true)) {
16131614
for (const CNetAddr& ip : vIPs) {
16141615
int nOneDay = 24*3600;
16151616
CAddress addr = CAddress(CService(ip, Params().GetDefaultPort()), requiredServiceBits);
@@ -1907,7 +1908,7 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo()
19071908
}
19081909

19091910
for (const std::string& strAddNode : lAddresses) {
1910-
CService service(LookupNumeric(strAddNode.c_str(), Params().GetDefaultPort()));
1911+
CService service(LookupNumeric(strAddNode, Params().GetDefaultPort()));
19111912
AddedNodeInfo addedNode{strAddNode, CService(), false, false};
19121913
if (service.IsValid()) {
19131914
// strAddNode is an IP:port

src/net_permissions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bool NetWhitebindPermissions::TryParse(const std::string str, NetWhitebindPermis
7171

7272
const std::string strBind = str.substr(offset);
7373
CService addrBind;
74-
if (!Lookup(strBind.c_str(), addrBind, 0, false)) {
74+
if (!Lookup(strBind, addrBind, 0, false)) {
7575
error = ResolveErrMsg("whitebind", strBind);
7676
return false;
7777
}
@@ -94,7 +94,7 @@ bool NetWhitelistPermissions::TryParse(const std::string str, NetWhitelistPermis
9494

9595
const std::string net = str.substr(offset);
9696
CSubNet subnet;
97-
LookupSubNet(net.c_str(), subnet);
97+
LookupSubNet(net, subnet);
9898
if (!subnet.IsValid()) {
9999
error = strprintf(_("Invalid netmask specified in -whitelist: '%s'").translated, net);
100100
return false;

src/netbase.cpp

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
#include <sync.h>
99
#include <tinyformat.h>
10-
#include <util/system.h>
1110
#include <util/strencodings.h>
11+
#include <util/string.h>
12+
#include <util/system.h>
1213

1314
#include <atomic>
1415

@@ -59,10 +60,14 @@ std::string GetNetworkName(enum Network net) {
5960
}
6061
}
6162

62-
bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
63+
bool static LookupIntern(const std::string& name, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
6364
{
6465
vIP.clear();
6566

67+
if (!ValidAsCString(name)) {
68+
return false;
69+
}
70+
6671
{
6772
CNetAddr addr;
6873
// From our perspective, onion addresses are not hostnames but rather
@@ -71,7 +76,7 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
7176
// getaddrinfo to decode them and it wouldn't make sense to resolve
7277
// them, we return a network address representing it instead. See
7378
// CNetAddr::SetSpecial(const std::string&) for more details.
74-
if (addr.SetSpecial(std::string(pszName))) {
79+
if (addr.SetSpecial(name)) {
7580
vIP.push_back(addr);
7681
return true;
7782
}
@@ -93,7 +98,7 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
9398
// hostname lookups.
9499
aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST;
95100
struct addrinfo *aiRes = nullptr;
96-
int nErr = getaddrinfo(pszName, nullptr, &aiHint, &aiRes);
101+
int nErr = getaddrinfo(name.c_str(), nullptr, &aiHint, &aiRes);
97102
if (nErr)
98103
return false;
99104

@@ -131,7 +136,7 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
131136
/**
132137
* Resolve a host string to its corresponding network addresses.
133138
*
134-
* @param pszName The string representing a host. Could be a name or a numerical
139+
* @param name The string representing a host. Could be a name or a numerical
135140
* IP address (IPv6 addresses in their bracketed form are
136141
* allowed).
137142
* @param[out] vIP The resulting network addresses to which the specified host
@@ -143,28 +148,34 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
143148
* @see Lookup(const char *, std::vector<CService>&, int, bool, unsigned int)
144149
* for additional parameter descriptions.
145150
*/
146-
bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
151+
bool LookupHost(const std::string& name, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
147152
{
148-
std::string strHost(pszName);
153+
if (!ValidAsCString(name)) {
154+
return false;
155+
}
156+
std::string strHost = name;
149157
if (strHost.empty())
150158
return false;
151159
if (strHost.front() == '[' && strHost.back() == ']') {
152160
strHost = strHost.substr(1, strHost.size() - 2);
153161
}
154162

155-
return LookupIntern(strHost.c_str(), vIP, nMaxSolutions, fAllowLookup);
163+
return LookupIntern(strHost, vIP, nMaxSolutions, fAllowLookup);
156164
}
157165

158166
/**
159167
* Resolve a host string to its first corresponding network address.
160168
*
161-
* @see LookupHost(const char *, std::vector<CNetAddr>&, unsigned int, bool) for
169+
* @see LookupHost(const std::string&, std::vector<CNetAddr>&, unsigned int, bool) for
162170
* additional parameter descriptions.
163171
*/
164-
bool LookupHost(const char *pszName, CNetAddr& addr, bool fAllowLookup)
172+
bool LookupHost(const std::string& name, CNetAddr& addr, bool fAllowLookup)
165173
{
174+
if (!ValidAsCString(name)) {
175+
return false;
176+
}
166177
std::vector<CNetAddr> vIP;
167-
LookupHost(pszName, vIP, 1, fAllowLookup);
178+
LookupHost(name, vIP, 1, fAllowLookup);
168179
if(vIP.empty())
169180
return false;
170181
addr = vIP.front();
@@ -174,7 +185,7 @@ bool LookupHost(const char *pszName, CNetAddr& addr, bool fAllowLookup)
174185
/**
175186
* Resolve a service string to its corresponding service.
176187
*
177-
* @param pszName The string representing a service. Could be a name or a
188+
* @param name The string representing a service. Could be a name or a
178189
* numerical IP address (IPv6 addresses should be in their
179190
* disambiguated bracketed form), optionally followed by a port
180191
* number. (e.g. example.com:8333 or
@@ -191,16 +202,17 @@ bool LookupHost(const char *pszName, CNetAddr& addr, bool fAllowLookup)
191202
* @returns Whether or not the service string successfully resolved to any
192203
* resulting services.
193204
*/
194-
bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
205+
bool Lookup(const std::string& name, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
195206
{
196-
if (pszName[0] == 0)
207+
if (name.empty() || !ValidAsCString(name)) {
197208
return false;
209+
}
198210
int port = portDefault;
199211
std::string hostname;
200-
SplitHostPort(std::string(pszName), port, hostname);
212+
SplitHostPort(name, port, hostname);
201213

202214
std::vector<CNetAddr> vIP;
203-
bool fRet = LookupIntern(hostname.c_str(), vIP, nMaxSolutions, fAllowLookup);
215+
bool fRet = LookupIntern(hostname, vIP, nMaxSolutions, fAllowLookup);
204216
if (!fRet)
205217
return false;
206218
vAddr.resize(vIP.size());
@@ -215,10 +227,13 @@ bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault,
215227
* @see Lookup(const char *, std::vector<CService>&, int, bool, unsigned int)
216228
* for additional parameter descriptions.
217229
*/
218-
bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLookup)
230+
bool Lookup(const std::string& name, CService& addr, int portDefault, bool fAllowLookup)
219231
{
232+
if (!ValidAsCString(name)) {
233+
return false;
234+
}
220235
std::vector<CService> vService;
221-
bool fRet = Lookup(pszName, vService, portDefault, fAllowLookup, 1);
236+
bool fRet = Lookup(name, vService, portDefault, fAllowLookup, 1);
222237
if (!fRet)
223238
return false;
224239
addr = vService[0];
@@ -235,12 +250,15 @@ bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLoo
235250
* @see Lookup(const char *, CService&, int, bool) for additional parameter
236251
* descriptions.
237252
*/
238-
CService LookupNumeric(const char *pszName, int portDefault)
253+
CService LookupNumeric(const std::string& name, int portDefault)
239254
{
255+
if (!ValidAsCString(name)) {
256+
return {};
257+
}
240258
CService addr;
241259
// "1.2:345" will fail to resolve the ip, but will still set the port.
242260
// If the ip fails to resolve, re-init the result.
243-
if(!Lookup(pszName, addr, portDefault, false))
261+
if(!Lookup(name, addr, portDefault, false))
244262
addr = CService();
245263
return addr;
246264
}
@@ -768,12 +786,11 @@ bool IsProxy(const CNetAddr &addr) {
768786
*
769787
* @returns Whether or not the operation succeeded.
770788
*/
771-
bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, const SOCKET& hSocket, int nTimeout, bool *outProxyConnectionFailed)
789+
bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, const SOCKET& hSocket, int nTimeout, bool& outProxyConnectionFailed)
772790
{
773791
// first connect to proxy server
774792
if (!ConnectSocketDirectly(proxy.proxy, hSocket, nTimeout, true)) {
775-
if (outProxyConnectionFailed)
776-
*outProxyConnectionFailed = true;
793+
outProxyConnectionFailed = true;
777794
return false;
778795
}
779796
// do socks negotiation
@@ -796,23 +813,25 @@ bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int
796813
* Parse and resolve a specified subnet string into the appropriate internal
797814
* representation.
798815
*
799-
* @param pszName A string representation of a subnet of the form `network
816+
* @param strSubnet A string representation of a subnet of the form `network
800817
* address [ "/", ( CIDR-style suffix | netmask ) ]`(e.g.
801818
* `2001:db8::/32`, `192.0.2.0/255.255.255.0`, or `8.8.8.8`).
802819
* @param ret The resulting internal representation of a subnet.
803820
*
804821
* @returns Whether the operation succeeded or not.
805822
*/
806-
bool LookupSubNet(const char* pszName, CSubNet& ret)
823+
bool LookupSubNet(const std::string& strSubnet, CSubNet& ret)
807824
{
808-
std::string strSubnet(pszName);
825+
if (!ValidAsCString(strSubnet)) {
826+
return false;
827+
}
809828
size_t slash = strSubnet.find_last_of('/');
810829
std::vector<CNetAddr> vIP;
811830

812831
std::string strAddress = strSubnet.substr(0, slash);
813-
// TODO: Use LookupHost(const char *, CNetAddr&, bool) instead to just get
832+
// TODO: Use LookupHost(const std::string&, CNetAddr&, bool) instead to just get
814833
// one CNetAddr.
815-
if (LookupHost(strAddress.c_str(), vIP, 1, false))
834+
if (LookupHost(strAddress, vIP, 1, false))
816835
{
817836
CNetAddr network = vIP[0];
818837
if (slash != strSubnet.npos)
@@ -827,7 +846,7 @@ bool LookupSubNet(const char* pszName, CSubNet& ret)
827846
else // If not a valid number, try full netmask syntax
828847
{
829848
// Never allow lookup for netmask
830-
if (LookupHost(strNetmask.c_str(), vIP, 1, false)) {
849+
if (LookupHost(strNetmask, vIP, 1, false)) {
831850
ret = CSubNet(network, vIP[0]);
832851
return ret.IsValid();
833852
}

src/netbase.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ bool IsProxy(const CNetAddr &addr);
4545
bool SetNameProxy(const proxyType &addrProxy);
4646
bool HaveNameProxy();
4747
bool GetNameProxy(proxyType &nameProxyOut);
48-
bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup);
49-
bool LookupHost(const char *pszName, CNetAddr& addr, bool fAllowLookup);
50-
bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLookup);
51-
bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions);
52-
CService LookupNumeric(const char *pszName, int portDefault = 0);
53-
bool LookupSubNet(const char *pszName, CSubNet& subnet);
48+
bool LookupHost(const std::string& name, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup);
49+
bool LookupHost(const std::string& name, CNetAddr& addr, bool fAllowLookup);
50+
bool Lookup(const std::string& name, CService& addr, int portDefault, bool fAllowLookup);
51+
bool Lookup(const std::string& name, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions);
52+
CService LookupNumeric(const std::string& name, int portDefault = 0);
53+
bool LookupSubNet(const std::string& strSubnet, CSubNet& subnet);
5454
SOCKET CreateSocket(const CService &addrConnect);
5555
bool ConnectSocketDirectly(const CService &addrConnect, const SOCKET& hSocketRet, int nTimeout, bool manual_connection);
56-
bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, const SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed);
56+
bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, const SOCKET& hSocketRet, int nTimeout, bool& outProxyConnectionFailed);
5757
/** Return readable error string for a network error code */
5858
std::string NetworkErrorString(int err);
5959
/** Close socket and set hSocket to INVALID_SOCKET */

src/qt/optionsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ QValidator::State ProxyAddressValidator::validate(QString &input, int &pos) cons
375375
{
376376
Q_UNUSED(pos);
377377
// Validate the proxy
378-
CService serv(LookupNumeric(input.toStdString().c_str(), DEFAULT_GUI_PROXY_PORT));
378+
CService serv(LookupNumeric(input.toStdString(), DEFAULT_GUI_PROXY_PORT));
379379
proxyType addrProxy = proxyType(serv, true);
380380
if (addrProxy.IsValid())
381381
return QValidator::Acceptable;

src/qt/rpcconsole.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ void RPCConsole::unbanSelectedNode()
12361236
QString strNode = nodes.at(i).data().toString();
12371237
CSubNet possibleSubnet;
12381238

1239-
LookupSubNet(strNode.toStdString().c_str(), possibleSubnet);
1239+
LookupSubNet(strNode.toStdString(), possibleSubnet);
12401240
if (possibleSubnet.IsValid() && m_node.unban(possibleSubnet))
12411241
{
12421242
clientModel->getBanTableModel()->refresh();

src/rpc/net.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,11 @@ static UniValue setban(const JSONRPCRequest& request)
562562

563563
if (!isSubnet) {
564564
CNetAddr resolved;
565-
LookupHost(request.params[0].get_str().c_str(), resolved, false);
565+
LookupHost(request.params[0].get_str(), resolved, false);
566566
netAddr = resolved;
567567
}
568568
else
569-
LookupSubNet(request.params[0].get_str().c_str(), subNet);
569+
LookupSubNet(request.params[0].get_str(), subNet);
570570

571571
if (! (isSubnet ? subNet.IsValid() : netAddr.IsValid()) )
572572
throw JSONRPCError(RPC_CLIENT_INVALID_IP_OR_SUBNET, "Error: Invalid IP/Subnet");

0 commit comments

Comments
 (0)