Commit 862eab28 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Ensure temporary string is NULL-terminated to avoid uninitialized…

crypt32: Ensure temporary string is NULL-terminated to avoid uninitialized memory access (valgrind).
parent c3bc7f2c
...@@ -789,7 +789,7 @@ static BOOL CRYPT_EncodeValueWithType(DWORD dwCertEncodingType, ...@@ -789,7 +789,7 @@ static BOOL CRYPT_EncodeValueWithType(DWORD dwCertEncodingType,
LONG i; LONG i;
LPWSTR ptr; LPWSTR ptr;
nameValue.Value.pbData = CryptMemAlloc((value->end - value->start) * nameValue.Value.pbData = CryptMemAlloc((value->end - value->start + 1) *
sizeof(WCHAR)); sizeof(WCHAR));
if (!nameValue.Value.pbData) if (!nameValue.Value.pbData)
{ {
...@@ -803,6 +803,11 @@ static BOOL CRYPT_EncodeValueWithType(DWORD dwCertEncodingType, ...@@ -803,6 +803,11 @@ static BOOL CRYPT_EncodeValueWithType(DWORD dwCertEncodingType,
if (value->start[i] == '"') if (value->start[i] == '"')
i++; i++;
} }
/* The string is NULL terminated because of a quirk in encoding
* unicode names values: if the length is given as 0, the value is
* assumed to be a NULL-terminated string.
*/
*ptr = 0;
nameValue.Value.cbData = (LPBYTE)ptr - nameValue.Value.pbData; nameValue.Value.cbData = (LPBYTE)ptr - nameValue.Value.pbData;
} }
ret = CryptEncodeObjectEx(dwCertEncodingType, X509_UNICODE_NAME_VALUE, ret = CryptEncodeObjectEx(dwCertEncodingType, X509_UNICODE_NAME_VALUE,
......
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