Skip to content

Commit fa7078d

Browse files
author
MacroFake
committed
scripted-diff: Rename ValidAsCString to ContainsNoNUL
-BEGIN VERIFY SCRIPT- sed -i 's,ValidAsCString,ContainsNoNUL,g' $(git grep -l ValidAsCString) -END VERIFY SCRIPT-
1 parent e7d2fbd commit fa7078d

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

src/base58.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ std::string EncodeBase58(Span<const unsigned char> input)
126126

127127
bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len)
128128
{
129-
if (!ValidAsCString(str)) {
129+
if (!ContainsNoNUL(str)) {
130130
return false;
131131
}
132132
return DecodeBase58(str.c_str(), vchRet, max_ret_len);
@@ -160,7 +160,7 @@ std::string EncodeBase58Check(Span<const unsigned char> input)
160160

161161
bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret)
162162
{
163-
if (!ValidAsCString(str)) {
163+
if (!ContainsNoNUL(str)) {
164164
return false;
165165
}
166166
return DecodeBase58Check(str.c_str(), vchRet, max_ret);

src/netaddress.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static void Checksum(Span<const uint8_t> addr_pubkey, uint8_t (&checksum)[CHECKS
210210

211211
bool CNetAddr::SetSpecial(const std::string& addr)
212212
{
213-
if (!ValidAsCString(addr)) {
213+
if (!ContainsNoNUL(addr)) {
214214
return false;
215215
}
216216

src/netbase.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static bool LookupIntern(const std::string& name, std::vector<CNetAddr>& vIP, un
136136
{
137137
vIP.clear();
138138

139-
if (!ValidAsCString(name)) {
139+
if (!ContainsNoNUL(name)) {
140140
return false;
141141
}
142142

@@ -169,7 +169,7 @@ static bool LookupIntern(const std::string& name, std::vector<CNetAddr>& vIP, un
169169

170170
bool LookupHost(const std::string& name, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function)
171171
{
172-
if (!ValidAsCString(name)) {
172+
if (!ContainsNoNUL(name)) {
173173
return false;
174174
}
175175
std::string strHost = name;
@@ -184,7 +184,7 @@ bool LookupHost(const std::string& name, std::vector<CNetAddr>& vIP, unsigned in
184184

185185
bool LookupHost(const std::string& name, CNetAddr& addr, bool fAllowLookup, DNSLookupFn dns_lookup_function)
186186
{
187-
if (!ValidAsCString(name)) {
187+
if (!ContainsNoNUL(name)) {
188188
return false;
189189
}
190190
std::vector<CNetAddr> vIP;
@@ -197,7 +197,7 @@ bool LookupHost(const std::string& name, CNetAddr& addr, bool fAllowLookup, DNSL
197197

198198
bool Lookup(const std::string& name, std::vector<CService>& vAddr, uint16_t portDefault, bool fAllowLookup, unsigned int nMaxSolutions, DNSLookupFn dns_lookup_function)
199199
{
200-
if (name.empty() || !ValidAsCString(name)) {
200+
if (name.empty() || !ContainsNoNUL(name)) {
201201
return false;
202202
}
203203
uint16_t port{portDefault};
@@ -216,7 +216,7 @@ bool Lookup(const std::string& name, std::vector<CService>& vAddr, uint16_t port
216216

217217
bool Lookup(const std::string& name, CService& addr, uint16_t portDefault, bool fAllowLookup, DNSLookupFn dns_lookup_function)
218218
{
219-
if (!ValidAsCString(name)) {
219+
if (!ContainsNoNUL(name)) {
220220
return false;
221221
}
222222
std::vector<CService> vService;
@@ -229,7 +229,7 @@ bool Lookup(const std::string& name, CService& addr, uint16_t portDefault, bool
229229

230230
CService LookupNumeric(const std::string& name, uint16_t portDefault, DNSLookupFn dns_lookup_function)
231231
{
232-
if (!ValidAsCString(name)) {
232+
if (!ContainsNoNUL(name)) {
233233
return {};
234234
}
235235
CService addr;
@@ -684,7 +684,7 @@ bool ConnectThroughProxy(const Proxy& proxy, const std::string& strDest, uint16_
684684

685685
bool LookupSubNet(const std::string& subnet_str, CSubNet& subnet_out)
686686
{
687-
if (!ValidAsCString(subnet_str)) {
687+
if (!ContainsNoNUL(subnet_str)) {
688688
return false;
689689
}
690690

src/test/fuzz/string.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool LegacyParsePrechecks(const std::string& str)
4242
return false;
4343
if (str.size() >= 1 && (IsSpace(str[0]) || IsSpace(str[str.size() - 1]))) // No padding allowed
4444
return false;
45-
if (!ValidAsCString(str)) // No embedded NUL characters allowed
45+
if (!ContainsNoNUL(str)) // No embedded NUL characters allowed
4646
return false;
4747
return true;
4848
}
@@ -188,7 +188,7 @@ FUZZ_TARGET(string)
188188
(void)TrimString(random_string_1);
189189
(void)TrimString(random_string_1, random_string_2);
190190
(void)urlDecode(random_string_1);
191-
(void)ValidAsCString(random_string_1);
191+
(void)ContainsNoNUL(random_string_1);
192192
(void)_(random_string_1.c_str());
193193
try {
194194
throw scriptnum_error{random_string_1};

src/util/moneystr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ std::string FormatMoney(const CAmount n)
4040

4141
std::optional<CAmount> ParseMoney(const std::string& money_string)
4242
{
43-
if (!ValidAsCString(money_string)) {
43+
if (!ContainsNoNUL(money_string)) {
4444
return std::nullopt;
4545
}
4646
const std::string str = TrimString(money_string);

src/util/string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ inline std::string MakeUnorderedList(const std::vector<std::string>& items)
9191
/**
9292
* Check if a string does not contain any embedded NUL (\0) characters
9393
*/
94-
[[nodiscard]] inline bool ValidAsCString(std::string_view str) noexcept
94+
[[nodiscard]] inline bool ContainsNoNUL(std::string_view str) noexcept
9595
{
9696
for (auto c : str) {
9797
if (c == 0) return false;

0 commit comments

Comments
 (0)