Restrict a2b_hex to 2000 bytes.
[ Merge of http://go/wvgerrit/109144 ] Because it doesn't help anybody when a buffer overflow test chokes the logger. Bug: 182058081 Test: Ran unit tests with verbose logging Change-Id: Ibcb3379b9eb9bdd94a8959b977e8de32ea116859
This commit is contained in:
@@ -254,6 +254,8 @@ std::vector<uint8_t> Base64SafeDecode(const std::string& b64_input) {
|
|||||||
std::string HexEncode(const uint8_t* in_buffer, unsigned int size) {
|
std::string HexEncode(const uint8_t* in_buffer, unsigned int size) {
|
||||||
static const char kHexChars[] = "0123456789ABCDEF";
|
static const char kHexChars[] = "0123456789ABCDEF";
|
||||||
if (size == 0) return "";
|
if (size == 0) return "";
|
||||||
|
constexpr unsigned int kMaxSafeSize = 2048;
|
||||||
|
if (size > kMaxSafeSize) size = kMaxSafeSize;
|
||||||
// Each input byte creates two output hex characters.
|
// Each input byte creates two output hex characters.
|
||||||
std::string out_buffer(size * 2, '\0');
|
std::string out_buffer(size * 2, '\0');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user