0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-02 09:46:52 -05:00

scripted-diff: Rename ValidAsCString to ContainsNoNUL

-BEGIN VERIFY SCRIPT-
 sed -i 's,ValidAsCString,ContainsNoNUL,g' $(git grep -l ValidAsCString)
-END VERIFY SCRIPT-
This commit is contained in:
MacroFake 2022-04-27 14:23:29 +02:00
parent e7d2fbda63
commit fa7078d84f
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
6 changed files with 14 additions and 14 deletions

View file

@ -126,7 +126,7 @@ std::string EncodeBase58(Span<const unsigned char> input)
bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len)
{
if (!ValidAsCString(str)) {
if (!ContainsNoNUL(str)) {
return false;
}
return DecodeBase58(str.c_str(), vchRet, max_ret_len);
@ -160,7 +160,7 @@ std::string EncodeBase58Check(Span<const unsigned char> input)
bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret)
{
if (!ValidAsCString(str)) {
if (!ContainsNoNUL(str)) {
return false;
}
return DecodeBase58Check(str.c_str(), vchRet, max_ret);

View file

@ -210,7 +210,7 @@ static void Checksum(Span<const uint8_t> addr_pubkey, uint8_t (&checksum)[CHECKS
bool CNetAddr::SetSpecial(const std::string& addr)
{
if (!ValidAsCString(addr)) {
if (!ContainsNoNUL(addr)) {
return false;
}

View file

@ -136,7 +136,7 @@ static bool LookupIntern(const std::string& name, std::vector<CNetAddr>& vIP, un
{
vIP.clear();
if (!ValidAsCString(name)) {
if (!ContainsNoNUL(name)) {
return false;
}
@ -169,7 +169,7 @@ static bool LookupIntern(const std::string& name, std::vector<CNetAddr>& vIP, un
bool LookupHost(const std::string& name, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function)
{
if (!ValidAsCString(name)) {
if (!ContainsNoNUL(name)) {
return false;
}
std::string strHost = name;
@ -184,7 +184,7 @@ bool LookupHost(const std::string& name, std::vector<CNetAddr>& vIP, unsigned in
bool LookupHost(const std::string& name, CNetAddr& addr, bool fAllowLookup, DNSLookupFn dns_lookup_function)
{
if (!ValidAsCString(name)) {
if (!ContainsNoNUL(name)) {
return false;
}
std::vector<CNetAddr> vIP;
@ -197,7 +197,7 @@ bool LookupHost(const std::string& name, CNetAddr& addr, bool fAllowLookup, DNSL
bool Lookup(const std::string& name, std::vector<CService>& vAddr, uint16_t portDefault, bool fAllowLookup, unsigned int nMaxSolutions, DNSLookupFn dns_lookup_function)
{
if (name.empty() || !ValidAsCString(name)) {
if (name.empty() || !ContainsNoNUL(name)) {
return false;
}
uint16_t port{portDefault};
@ -216,7 +216,7 @@ bool Lookup(const std::string& name, std::vector<CService>& vAddr, uint16_t port
bool Lookup(const std::string& name, CService& addr, uint16_t portDefault, bool fAllowLookup, DNSLookupFn dns_lookup_function)
{
if (!ValidAsCString(name)) {
if (!ContainsNoNUL(name)) {
return false;
}
std::vector<CService> vService;
@ -229,7 +229,7 @@ bool Lookup(const std::string& name, CService& addr, uint16_t portDefault, bool
CService LookupNumeric(const std::string& name, uint16_t portDefault, DNSLookupFn dns_lookup_function)
{
if (!ValidAsCString(name)) {
if (!ContainsNoNUL(name)) {
return {};
}
CService addr;
@ -684,7 +684,7 @@ bool ConnectThroughProxy(const Proxy& proxy, const std::string& strDest, uint16_
bool LookupSubNet(const std::string& subnet_str, CSubNet& subnet_out)
{
if (!ValidAsCString(subnet_str)) {
if (!ContainsNoNUL(subnet_str)) {
return false;
}

View file

@ -42,7 +42,7 @@ bool LegacyParsePrechecks(const std::string& str)
return false;
if (str.size() >= 1 && (IsSpace(str[0]) || IsSpace(str[str.size() - 1]))) // No padding allowed
return false;
if (!ValidAsCString(str)) // No embedded NUL characters allowed
if (!ContainsNoNUL(str)) // No embedded NUL characters allowed
return false;
return true;
}
@ -188,7 +188,7 @@ FUZZ_TARGET(string)
(void)TrimString(random_string_1);
(void)TrimString(random_string_1, random_string_2);
(void)urlDecode(random_string_1);
(void)ValidAsCString(random_string_1);
(void)ContainsNoNUL(random_string_1);
(void)_(random_string_1.c_str());
try {
throw scriptnum_error{random_string_1};

View file

@ -40,7 +40,7 @@ std::string FormatMoney(const CAmount n)
std::optional<CAmount> ParseMoney(const std::string& money_string)
{
if (!ValidAsCString(money_string)) {
if (!ContainsNoNUL(money_string)) {
return std::nullopt;
}
const std::string str = TrimString(money_string);

View file

@ -91,7 +91,7 @@ inline std::string MakeUnorderedList(const std::vector<std::string>& items)
/**
* Check if a string does not contain any embedded NUL (\0) characters
*/
[[nodiscard]] inline bool ValidAsCString(std::string_view str) noexcept
[[nodiscard]] inline bool ContainsNoNUL(std::string_view str) noexcept
{
for (auto c : str) {
if (c == 0) return false;