Commit fbafa847 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

base64: prevent crash in case of empty input

Change-Id: I2bfbde86083829d553a1f79e1c91aed4b2bedd6f
parent 321f83d8
......@@ -33,6 +33,9 @@ encode(const std::vector<uint8_t>::const_iterator begin,
const std::vector<uint8_t>::const_iterator end)
int input_length = std::distance(begin, end);
if (input_length == 0)
return {};
int output_length = PJ_BASE256_TO_BASE64_LEN(input_length);
std::string out;
......@@ -54,6 +57,9 @@ encode(const std::vector<uint8_t>& dat)
decode(const std::string& str)
if (str.empty())
return {};
int output_length = PJ_BASE64_TO_BASE256_LEN(str.length());
const pj_str_t input(sip_utils::CONST_PJ_STR(str));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment