crypt32: Fix up decoding.

- don't use the no copy flag when decoding, the lifetime of the buffer
  to decode isn't guaranteed
- remove some extraneous ternary comparisons
- fix a comment
This commit is contained in:
Juan Lang 2006-02-09 12:09:28 +01:00 committed by Alexandre Julliard
parent 02c4956157
commit 69698f9b44
1 changed files with 5 additions and 7 deletions

View File

@ -552,7 +552,7 @@ static void CRYPT_MemEmptyStore(PWINE_MEMSTORE store)
PWINE_CERT_LIST_ENTRY cert, next; PWINE_CERT_LIST_ENTRY cert, next;
EnterCriticalSection(&store->cs); EnterCriticalSection(&store->cs);
/* Note that CertFreeCertificateContext calls HeapFree on the passed-in /* Note that CertFreeCertificateContext calls CryptMemFree on the passed-in
* pointer if its ref-count reaches zero. That's okay here because there * pointer if its ref-count reaches zero. That's okay here because there
* aren't any allocated data outside of the WINE_CERT_CONTEXT_REF portion * aren't any allocated data outside of the WINE_CERT_CONTEXT_REF portion
* of the CertListEntry. * of the CertListEntry.
@ -1939,15 +1939,13 @@ static PWINE_CERT_CONTEXT CRYPT_CreateCertificateContext(
/* First try to decode it as a signed cert. */ /* First try to decode it as a signed cert. */
ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_CERT, pbCertEncoded, ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_CERT, pbCertEncoded,
cbCertEncoded, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, NULL, cbCertEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&signedCert, &size);
(BYTE *)&signedCert, &size);
if (ret) if (ret)
{ {
size = 0; size = 0;
ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED,
signedCert->ToBeSigned.pbData, signedCert->ToBeSigned.cbData, signedCert->ToBeSigned.pbData, signedCert->ToBeSigned.cbData,
CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, NULL, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&certInfo, &size);
(BYTE *)&certInfo, &size);
LocalFree(signedCert); LocalFree(signedCert);
} }
/* Failing that, try it as an unsigned cert */ /* Failing that, try it as an unsigned cert */
@ -2241,7 +2239,7 @@ static BOOL CRYPT_SaveCertificateContextProperty(PWINE_CERT_CONTEXT context,
{ {
CryptMemFree(prop->pbData); CryptMemFree(prop->pbData);
prop->hdr.cb = cbData; prop->hdr.cb = cbData;
prop->pbData = cbData ? data : NULL; prop->pbData = data;
ret = TRUE; ret = TRUE;
} }
else else
@ -2253,7 +2251,7 @@ static BOOL CRYPT_SaveCertificateContextProperty(PWINE_CERT_CONTEXT context,
prop->hdr.unknown = 1; prop->hdr.unknown = 1;
prop->hdr.cb = cbData; prop->hdr.cb = cbData;
list_init(&prop->entry); list_init(&prop->entry);
prop->pbData = cbData ? data : NULL; prop->pbData = data;
list_add_tail(&context->extendedProperties, &prop->entry); list_add_tail(&context->extendedProperties, &prop->entry);
ret = TRUE; ret = TRUE;
} }