VirtualBox

Changeset 107457 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jan 7, 2025 10:54:10 AM (5 weeks ago)
Author:
vboxsync
Message:

Devices/PC/DevACPI.cpp: Add missing error check, and re-arrange code reading custom ACPI tables to actually return an error if the check fails and not continue regardless, bugref:3409

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevACPI.cpp

    r106061 r107457  
    23292329    AssertRCReturn(rc, rc);
    23302330    rc = PDMDevHlpIoPortMap(pDevIns, pThis->hIoPortGpe0En,  acpiR3CalcPmPort(pThis, GPE0_OFFSET + GPE0_BLK_LEN / 2));
     2331    AssertRCReturn(rc, rc);
    23312332
    23322333    return VINF_SUCCESS;
     
    36803681        {
    36813682            /* The following checks should be in sync the AssertReleaseMsg's below. */
    3682             if (    *pcbCustBin > cbBufAvail
    3683                 ||  *pcbCustBin < sizeof(ACPITBLHEADER))
    3684                 rc = VERR_TOO_MUCH_DATA;
    3685 
    3686             /*
    3687              * Allocate buffer for the custom table binary data.
    3688              */
    3689             *ppu8CustBin = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, *pcbCustBin);
    3690             if (*ppu8CustBin)
     3683            if (    *pcbCustBin <= cbBufAvail
     3684                &&  *pcbCustBin > sizeof(ACPITBLHEADER))
    36913685            {
    3692                 rc = RTFileRead(FileCUSTBin, *ppu8CustBin, *pcbCustBin, NULL);
    3693                 if (RT_FAILURE(rc))
     3686                /*
     3687                 * Allocate buffer for the custom table binary data.
     3688                 */
     3689                *ppu8CustBin = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, *pcbCustBin);
     3690                if (*ppu8CustBin)
    36943691                {
    3695                     AssertMsgFailed(("RTFileRead(,,%d,NULL) -> %Rrc\n", *pcbCustBin, rc));
    3696                     PDMDevHlpMMHeapFree(pDevIns, *ppu8CustBin);
    3697                     *ppu8CustBin = NULL;
     3692                    rc = RTFileRead(FileCUSTBin, *ppu8CustBin, *pcbCustBin, NULL);
     3693                    if (RT_FAILURE(rc))
     3694                    {
     3695                        AssertMsgFailed(("RTFileRead(,,%d,NULL) -> %Rrc\n", *pcbCustBin, rc));
     3696                        PDMDevHlpMMHeapFree(pDevIns, *ppu8CustBin);
     3697                        *ppu8CustBin = NULL;
     3698                    }
    36983699                }
     3700                else
     3701                    rc = VERR_NO_MEMORY;
    36993702            }
    37003703            else
    3701             {
    3702                 rc = VERR_NO_MEMORY;
    3703             }
     3704                rc = VERR_TOO_MUCH_DATA;
     3705
    37043706            RTFileClose(FileCUSTBin);
    37053707        }
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