MCPcopy Create free account
hub / github.com/ElementsProject/elements / LegacyParseUInt64

Function LegacyParseUInt64

src/test/fuzz/string.cpp:110–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110bool LegacyParseUInt64(const std::string& str, uint64_t* out)
111{
112 if (!LegacyParsePrechecks(str))
113 return false;
114 if (str.size() >= 1 && str[0] == '-') // Reject negative values, unfortunately strtoull accepts these by default if they fit in the range
115 return false;
116 char* endp = nullptr;
117 errno = 0; // strtoull will not set errno if valid
118 unsigned long long int n = strtoull(str.c_str(), &endp, 10);
119 if (out) *out = (uint64_t)n;
120 // Note that strtoull returns a *unsigned long long int*, so even if it doesn't report an over/underflow
121 // we still have to check that the returned value is within the range of an *uint64_t*.
122 return endp && *endp == 0 && !errno &&
123 n <= std::numeric_limits<uint64_t>::max();
124}
125
126// For backwards compatibility checking.
127int64_t atoi64_legacy(const std::string& str)

Callers 1

FUZZ_TARGETFunction · 0.85

Calls 2

LegacyParsePrechecksFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected