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

Method ConsumeBytesAsString

src/test/fuzz/FuzzedDataProvider.h:136–145  ·  view source on GitHub ↗

Returns a std::string containing |num_bytes| of input data. Using this and |.c_str()| on the resulting string is the best way to get an immutable null-terminated C string. If fewer than |num_bytes| of data remain, returns a shorter std::string containing all of the data that's left.

Source from the content-addressed store, hash-verified

134// null-terminated C string. If fewer than |num_bytes| of data remain, returns
135// a shorter std::string containing all of the data that's left.
136inline std::string FuzzedDataProvider::ConsumeBytesAsString(size_t num_bytes) {
137 static_assert(sizeof(std::string::value_type) == sizeof(uint8_t),
138 "ConsumeBytesAsString cannot convert the data to a string.");
139
140 num_bytes = std::min(num_bytes, remaining_bytes_);
141 std::string result(
142 reinterpret_cast<const std::string::value_type *>(data_ptr_), num_bytes);
143 Advance(num_bytes);
144 return result;
145}
146
147// Returns a std::string of length from 0 to |max_length|. When it runs out of
148// input data, returns what remains of the input. Designed to be more stable

Callers 5

fuzz_targetFunction · 0.80
FUZZ_TARGETFunction · 0.80
FUZZ_TARGET_INITFunction · 0.80
FUZZ_TARGETFunction · 0.80
ConsumeNetAddrFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected