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:
Rahul Frias
2021-03-07 22:13:47 -08:00
parent 616a9b38dc
commit 9a659e31c1

View File

@@ -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) {
static const char kHexChars[] = "0123456789ABCDEF";
if (size == 0) return "";
constexpr unsigned int kMaxSafeSize = 2048;
if (size > kMaxSafeSize) size = kMaxSafeSize;
// Each input byte creates two output hex characters.
std::string out_buffer(size * 2, '\0');