VirtualBox

Ignore:
Timestamp:
Feb 10, 2008 7:44:59 PM (17 years ago)
Author:
vboxsync
Message:

DMI: made size consistent, removed double size check, fix error message

File:
1 edited

Legend:

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

    r6873 r6876  
    844844    do { \
    845845        size_t _len = strlen(s) + 1; \
    846         if (pszStr + _len - (char *)pTable >= cbMax) \
     846        size_t _max = (unsigned)(pszStr + _len - (char *)pTable) + 1; \
     847        if (_max > cbMax) \
    847848            return PDMDevHlpVMSetError(pDevIns, VERR_TOO_MUCH_DATA, RT_SRC_POS, \
    848                     N_("DMI string too long (%zu): \"%s\""), _len, s); \
     849                    N_("One of the DMI strings is too long. Check all bios/Dmi* configuration entries. At least %zu bytes are needed but there is no space for more than %d bytes"), _max, cbMax); \
    849850        memcpy(p, s, _len); \
    850851        p += _len; \
     
    874875    READCFG("DmiFamily",  pszDmiFamily,   "Virtual Machine");
    875876
     877    /* DMI BIOS information */
    876878    PDMIBIOSINF pBIOSInf         = (PDMIBIOSINF)pszStr;
    877879    pszStr                       = (char *)(pBIOSInf + 1);
     
    904906    *pszStr++                    = '\0';
    905907
    906 
     908    /* DMI system information */
    907909    PDMISYSTEMINF pSystemInf     = (PDMISYSTEMINF)pszStr;
    908910    pszStr                       = (char *)(pSystemInf + 1);
     
    940942    *pszStr++                    = '\0';
    941943
     944    /* If more fields are added here, fix the size check in STRCPY */
     945
    942946#undef STRCPY
    943947#undef READCFG
    944 
    945     if (pszStr - (char *)pTable > VBOX_DMI_TABLE_SIZE)
    946         return PDMDevHlpVMSetError(pDevIns, VERR_BUFFER_OVERFLOW, RT_SRC_POS,
    947                                    N_("DMI table too long (have=%d, max=%d)"),
    948                                    pszStr - (char *)pTable, VBOX_DMI_TABLE_SIZE);
    949948
    950949    MMR3HeapFree(pszDmiVendor);
     
    13731372    uuid.Gen.u16TimeMid = RT_H2BE_U16(uuid.Gen.u16TimeMid);
    13741373    uuid.Gen.u16TimeHiAndVersion = RT_H2BE_U16(uuid.Gen.u16TimeHiAndVersion);
    1375     rc = pcbiosPlantDMITable(pDevIns, pData->au8DMIPage, 0x100 /* see below */, &uuid, pCfgHandle);
     1374    rc = pcbiosPlantDMITable(pDevIns, pData->au8DMIPage, VBOX_DMI_TABLE_SIZE, &uuid, pCfgHandle);
    13761375    if (VBOX_FAILURE(rc))
    13771376        return rc;
    13781377    if (pData->u8IOAPIC)
    1379         pcbiosPlantMPStable(pDevIns, pData->au8DMIPage + 0x100);
     1378        pcbiosPlantMPStable(pDevIns, pData->au8DMIPage + VBOX_DMI_TABLE_SIZE);
    13801379
    13811380    rc = PDMDevHlpROMRegister(pDevIns, VBOX_DMI_TABLE_BASE, 0x1000, pData->au8DMIPage, false /* fShadow */, "DMI tables");
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