Merge "Stop writing NUL bytes in adbkey.pub."

am: d340c1ebbe

Change-Id: Ia0980152cdd937c440aa42c36577670d1e853eea
This commit is contained in:
Elliott Hughes 2017-05-02 00:55:01 +00:00 committed by android-build-merger
commit 68c9642a9d
1 changed files with 6 additions and 5 deletions

View File

@ -82,16 +82,17 @@ static bool write_public_keyfile(RSA* private_key, const std::string& private_ke
return false;
}
size_t base64_key_length;
if (!EVP_EncodedLength(&base64_key_length, sizeof(binary_key_data))) {
size_t expected_length;
if (!EVP_EncodedLength(&expected_length, sizeof(binary_key_data))) {
LOG(ERROR) << "Public key too large to base64 encode";
return false;
}
std::string content;
content.resize(base64_key_length);
base64_key_length = EVP_EncodeBlock(reinterpret_cast<uint8_t*>(&content[0]), binary_key_data,
sizeof(binary_key_data));
content.resize(expected_length);
size_t actual_length = EVP_EncodeBlock(reinterpret_cast<uint8_t*>(&content[0]), binary_key_data,
sizeof(binary_key_data));
content.resize(actual_length);
content += get_user_info();