Commit 44ee6263 authored by Adam Langley's avatar Adam Langley Committed by Shawn Willden
Browse files

system/security/softkeymaster: don't pass a structure into |d2i_PrivateKey|.

Some OpenSSL parsing functions have, historically, allowed a structure
to be passed in to reuse that memory. There have been many bugs arising
from this corner case and it's generally best to avoid it.

This change just passes in NULL because a new structure was being
allocated anyway. Also, the API didn't guarantee that the memory would
always be reused – code had to check the updated pointer, which this
didn't do. So it might have broken in the future.

Change-Id: Iba98f9d11ece457cf6b66e2637bb8cb23f5930d2
parent a1433ee2
......@@ -208,17 +208,11 @@ static EVP_PKEY* unwrap_key(const uint8_t* keyBlob, const size_t keyBlobLength)
return NULL;
}
Unique_EVP_PKEY pkey(EVP_PKEY_new());
Unique_EVP_PKEY pkey(d2i_PrivateKey(type, nullptr, &p, privateLen));
if (pkey.get() == NULL) {
logOpenSSLError("unwrap_key");
return NULL;
}
EVP_PKEY* tmp = pkey.get();
if (d2i_PrivateKey(type, &tmp, &p, privateLen) == NULL) {
logOpenSSLError("unwrap_key");
return NULL;
}
return pkey.release();
}
......
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