VirtualBox

Changeset 97465 in vbox


Ignore:
Timestamp:
Nov 8, 2022 9:46:10 PM (2 years ago)
Author:
vboxsync
Message:

IPRT/crypto: Corrected and unified the error checking of d2i_TYPE calls and corrected a i2d_TYPE one. Kudos to fth0 for finding these. ticketref:21097

Location:
trunk/src/VBox/Runtime/common/crypto
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/crypto/iprt-openssl.cpp

    r96407 r97465  
    111111        X509 *pOsslCertRet = d2i_X509(&pOsslCert, &pabEncoded, cbEncoded);
    112112        RTMemTmpFree(pvFree);
    113         if (pOsslCertRet == pOsslCert)
     113        if (pOsslCert != NULL && pOsslCertRet == pOsslCert)
    114114        {
    115115            *ppvOsslCert = pOsslCert;
     
    181181        X509_ATTRIBUTE *pOsslAttribRet = d2i_X509_ATTRIBUTE(&pOsslAttrib, &pabEncoded, cbEncoded);
    182182        RTMemTmpFree(pvFree);
    183         if (pOsslAttribRet == pOsslAttrib)
     183        if (pOsslAttrib != NULL && pOsslAttribRet == pOsslAttrib)
    184184        {
    185185            *ppvOsslAttrib = pOsslAttrib;
  • trunk/src/VBox/Runtime/common/crypto/key-create-rsa-openssl.cpp

    r96407 r97465  
    8484                    unsigned char *pbRsaPrivateKey = NULL;
    8585                    int cbRsaPrivateKey = i2d_RSAPrivateKey(pRsa, &pbRsaPrivateKey);
    86                     if (cbRsaPrivateKey)
     86                    if (cbRsaPrivateKey > 0)
    8787                    {
    8888                        rc = rtCrKeyCreateRsaPrivate(phKey, pbRsaPrivateKey, cbRsaPrivateKey, NULL, NULL);
  • trunk/src/VBox/Runtime/common/crypto/key-openssl.cpp

    r96763 r97465  
    111111    else
    112112        *ppEvpKey = pRet = d2i_PrivateKey(idKeyType, &pEvpNewKey, &puchPublicKey, hKey->cbEncoded);
    113     if (pRet)
     113    if (pRet != NULL && pRet == pEvpNewKey)
    114114        return VINF_SUCCESS;
    115115
     
    204204            else
    205205                *ppEvpKey = pRet = d2i_PrivateKey(idKeyType, &pEvpNewKey, &puchPublicKey, hKey->cbEncoded);
    206             if (pRet)
     206            if (pRet != NULL && pRet == pEvpNewKey)
    207207                return VINF_SUCCESS;
    208208
  • trunk/src/VBox/Runtime/common/crypto/pkcs7-verify.cpp

    r96959 r97465  
    7979    AssertRCReturn(rcOssl, rcOssl);
    8080
    81     PKCS7 *pOsslPkcs7   = NULL;
     81    PKCS7 *pOsslPkcs7    = NULL;
    8282    PKCS7 *pOsslPkcs7Ret = d2i_PKCS7(&pOsslPkcs7, &pbRawContent, cbRawContent);
    8383
    8484    RTMemTmpFree(pvFree);
    8585
    86     if (pOsslPkcs7Ret != NULL)
     86    if (pOsslPkcs7 != NULL && pOsslPkcs7Ret == pOsslPkcs7)
    8787    {
    8888        STACK_OF(X509) *pAddCerts = NULL;
  • trunk/src/VBox/Runtime/common/crypto/store.cpp

    r96407 r97465  
    445445                    && pCertCtx->cbEncoded > 0)
    446446                {
    447                     X509 *pOsslCert = NULL;
     447                    X509                *pOsslCert = NULL;
    448448                    const unsigned char *pabEncoded = (const unsigned char *)pCertCtx->pabEncoded;
    449                     if (d2i_X509(&pOsslCert, &pabEncoded, pCertCtx->cbEncoded) == pOsslCert)
     449                    if (d2i_X509(&pOsslCert, &pabEncoded, pCertCtx->cbEncoded) == pOsslCert && pOsslCert != NULL)
    450450                    {
    451451                        if (!X509_STORE_add_cert(pOsslStore, pOsslCert))
     
    501501                    && pCertCtx->cbEncoded > 0)
    502502                {
    503                     X509 *pOsslCert = NULL;
     503                    X509                *pOsslCert = NULL;
    504504                    const unsigned char *pabEncoded = (const unsigned char *)pCertCtx->pabEncoded;
    505                     if (d2i_X509(&pOsslCert, &pabEncoded, pCertCtx->cbEncoded) == pOsslCert)
     505                    if (d2i_X509(&pOsslCert, &pabEncoded, pCertCtx->cbEncoded) == pOsslCert && pOsslCert != NULL)
    506506                    {
    507507                        if (!sk_X509_push(pOsslStack, pOsslCert))
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette