VirtualBox

Changeset 90285 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Jul 22, 2021 11:59:15 AM (4 years ago)
Author:
vboxsync
Message:

Runtime/efi: Started implementing the functionality to parse, create and modify EFI signature databases, bugref:9580 [build fix]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/efi/efisignaturedb.cpp

    r90283 r90285  
    6060    RTUUID                  UuidOwner;
    6161    /** Size of the signature data in bytes. */
    62     size_t                  cbSignature;
     62    uint32_t                cbSignature;
    6363    /** The signature data (variable in size). */
    6464    RT_FLEXIBLE_ARRAY_EXTENSION
     
    9191    EFI_GUID                GuidSignatureType;
    9292    /** The additional signature header for this signature type. */
    93     size_t                  cbSigHdr;
     93    uint32_t                cbSigHdr;
    9494    /** Size of the signature data (including EFI_SIGNATURE_DATA),
    9595     * can be 0 size varies with each signature (X.509 for example). */
    96     size_t                  cbSig;
     96    uint32_t                cbSig;
    9797    /** The internal signature type enum. */
    9898    RTEFISIGTYPE            enmSigType;
     
    378378 * @param   cbSig               Size of the signature data in bytes.
    379379 */
    380 static PRTEFISIGNATURE rtEfiSigDbAllocSignature(PCRTUUID pUuidOwner, size_t cbSig)
     380static PRTEFISIGNATURE rtEfiSigDbAllocSignature(PCRTUUID pUuidOwner, uint32_t cbSig)
    381381{
    382382    PRTEFISIGNATURE pSig = (PRTEFISIGNATURE)RTMemAllocZ(RT_UOFFSETOF_DYN(RTEFISIGNATURE, abSignature[cbSig]));
     
    463463    if (RT_SUCCESS(rc))
    464464    {
    465         if (   !pDesc->cbSig
    466             || pDesc->cbSig - sizeof(EFI_SIGNATURE_DATA) == cbSig)
    467         {
    468             PRTEFISIGNATURE pSig = rtEfiSigDbAllocSignature(pUuidOwner, cbSig);
     465        if (   (   !pDesc->cbSig
     466                || pDesc->cbSig - sizeof(EFI_SIGNATURE_DATA) == cbSig)
     467            && cbSig < UINT32_MAX)
     468        {
     469            PRTEFISIGNATURE pSig = rtEfiSigDbAllocSignature(pUuidOwner, (uint32_t)cbSig);
    469470            if (pSig)
    470471            {
    471                 rc = RTVfsFileRead(hVfsFileIn, &pSig->abSignature[0], cbSig, NULL /*pcbRead*/);
     472                rc = RTVfsFileRead(hVfsFileIn, &pSig->abSignature[0], (size_t)cbSig, NULL /*pcbRead*/);
    472473                if (RT_SUCCESS(rc))
    473474                    RTListAppend(&pThis->aLstSigTypes[enmSigType], &pSig->NdLst);
     
    494495    AssertPtrReturn(pUuidOwner, VERR_INVALID_POINTER);
    495496    AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
    496     AssertReturn(cbBuf, VERR_INVALID_PARAMETER);
     497    AssertReturn(cbBuf && cbBuf < UINT32_MAX, VERR_INVALID_PARAMETER);
    497498
    498499    int rc = VINF_SUCCESS;
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