VirtualBox

Changeset 11428 in vbox for trunk


Ignore:
Timestamp:
Aug 14, 2008 3:27:05 PM (16 years ago)
Author:
vboxsync
Message:

BIOS: handle empty DMI strings

File:
1 edited

Legend:

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

    r11284 r11428  
    832832    char *pszDmiSystemVendor, *pszDmiSystemProduct, *pszDmiSystemVersion, *pszDmiSystemSerial, *pszDmiSystemUuid, *pszDmiSystemFamily;
    833833
    834 #define STRCPY(p, s) \
     834#define SETSTRING(memb, str) \
    835835    do { \
    836         size_t _len = strlen(s) + 1; \
    837         size_t _max = (size_t)(pszStr + _len - (char *)pTable) + 5; /* +1 for strtab terminator +4 for end-of-table entry */ \
    838         if (_max > cbMax) \
     836        if (!str[0]) \
     837          memb = 0; /* empty string */ \
     838        else \
     839        { \
     840          memb = iStrNr++; \
     841          size_t _len = strlen(str) + 1; \
     842          size_t _max = (size_t)(pszStr + _len - (char *)pTable) + 5; /* +1 for strtab terminator +4 for end-of-table entry */ \
     843          if (_max > cbMax) \
    839844            return PDMDevHlpVMSetError(pDevIns, VERR_TOO_MUCH_DATA, RT_SRC_POS, \
    840845                    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); \
    841         memcpy(p, s, _len); \
    842         p += _len; \
     846          memcpy(pszStr, str, _len); \
     847          pszStr += _len; \
     848        } \
    843849    } while (0)
    844850#define READCFGSTR(name, variable, default_value) \
     
    850856            return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, \
    851857                    N_("Configuration error: Querying \"" name "\" as a string failed")); \
     858        else if (!strcmp(variable, "<EMPTY>")) \
     859            variable[0] = '\0'; \
    852860    } while (0)
    853861#define READCFGINT(name, variable, default_value) \
     
    909917    pBIOSInf->header.u8Type      = 0; /* BIOS Information */
    910918    pBIOSInf->header.u16Handle   = 0x0000;
    911     pBIOSInf->u8Vendor           = iStrNr++;
    912     STRCPY(pszStr, pszDmiBIOSVendor);
    913     pBIOSInf->u8Version          = iStrNr++;
    914     STRCPY(pszStr, pszDmiBIOSVersion);
     919    SETSTRING(pBIOSInf->u8Vendor,  pszDmiBIOSVendor);
     920    SETSTRING(pBIOSInf->u8Version, pszDmiBIOSVersion);
    915921    pBIOSInf->u16Start           = 0xE000;
    916     pBIOSInf->u8Release          = iStrNr++;
    917     STRCPY(pszStr, pszDmiBIOSReleaseDate);
     922    SETSTRING(pBIOSInf->u8Release, pszDmiBIOSReleaseDate);
    918923    pBIOSInf->u8ROMSize          = 1; /* 128K */
    919924    pBIOSInf->u64Characteristics = RT_BIT(4)   /* ISA is supported */
     
    940945    pSystemInf->header.u8Length  = sizeof(*pSystemInf);
    941946    pSystemInf->header.u16Handle = 0x0001;
    942     pSystemInf->u8Manufacturer   = iStrNr++;
    943     STRCPY(pszStr, pszDmiSystemVendor);
    944     pSystemInf->u8ProductName    = iStrNr++;
    945     STRCPY(pszStr, pszDmiSystemProduct);
    946     pSystemInf->u8Version        = iStrNr++;
    947     STRCPY(pszStr, pszDmiSystemVersion);
    948     pSystemInf->u8SerialNumber   = iStrNr++;
    949     STRCPY(pszStr, pszDmiSystemSerial);
     947    SETSTRING(pSystemInf->u8Manufacturer, pszDmiSystemVendor);
     948    SETSTRING(pSystemInf->u8ProductName,  pszDmiSystemProduct);
     949    SETSTRING(pSystemInf->u8Version,      pszDmiSystemVersion);
     950    SETSTRING(pSystemInf->u8SerialNumber, pszDmiSystemSerial);
    950951
    951952    RTUUID uuid;
     
    965966    pSystemInf->u8WakeupType     = 6; /* Power Switch */
    966967    pSystemInf->u8SKUNumber      = 0;
    967     pSystemInf->u8Family         = iStrNr++;
    968     STRCPY(pszStr, pszDmiSystemFamily);
     968    SETSTRING(pSystemInf->u8Family, pszDmiSystemFamily);
    969969    *pszStr++                    = '\0';
    970970
     
    975975    pEndOfTable->u16Handle       = 0xFFFF;
    976976
    977     /* If more fields are added here, fix the size check in STRCPY */
    978 
    979 #undef STRCPY
     977    /* If more fields are added here, fix the size check in SETSTRING */
     978
     979#undef SETSTRING
    980980#undef READCFG
    981981
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