mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Eliminate potential undefined behavior (RIPD-1685):
Under certain conditions, we could call `memcpy` or `memcmp` with a null source pointer. Even when specifying 0 as the amount of data to copy this could result in undefined behavior under the C and C++ standards. Acknowledgements: Ripple thanks Guido Vranken for responsibly disclosing these issues. Bug Bounties and Responsible Disclosures: We welcome reviews of the rippled code and urge researchers to responsibly disclose any issues that they may find. For more on Ripple's Bug Bounty program, please visit: https://ripple.com/bug-bounty
This commit is contained in:
@@ -49,14 +49,14 @@ public:
|
||||
mData.reserve (n);
|
||||
}
|
||||
|
||||
Serializer (void const* data,
|
||||
std::size_t size)
|
||||
Serializer (void const* data, std::size_t size)
|
||||
{
|
||||
assert(!data == !size);
|
||||
|
||||
mData.resize(size);
|
||||
std::memcpy(mData.data(),
|
||||
reinterpret_cast<
|
||||
unsigned char const*>(
|
||||
data), size);
|
||||
|
||||
if (size)
|
||||
std::memcpy(mData.data(), data, size);
|
||||
}
|
||||
|
||||
Slice slice() const noexcept
|
||||
|
||||
Reference in New Issue
Block a user