- Timestamp:
- Aug 14, 2008 3:27:05 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevPcBios.cpp
r11284 r11428 832 832 char *pszDmiSystemVendor, *pszDmiSystemProduct, *pszDmiSystemVersion, *pszDmiSystemSerial, *pszDmiSystemUuid, *pszDmiSystemFamily; 833 833 834 #define S TRCPY(p, s) \834 #define SETSTRING(memb, str) \ 835 835 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) \ 839 844 return PDMDevHlpVMSetError(pDevIns, VERR_TOO_MUCH_DATA, RT_SRC_POS, \ 840 845 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 } \ 843 849 } while (0) 844 850 #define READCFGSTR(name, variable, default_value) \ … … 850 856 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, \ 851 857 N_("Configuration error: Querying \"" name "\" as a string failed")); \ 858 else if (!strcmp(variable, "<EMPTY>")) \ 859 variable[0] = '\0'; \ 852 860 } while (0) 853 861 #define READCFGINT(name, variable, default_value) \ … … 909 917 pBIOSInf->header.u8Type = 0; /* BIOS Information */ 910 918 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); 915 921 pBIOSInf->u16Start = 0xE000; 916 pBIOSInf->u8Release = iStrNr++; 917 STRCPY(pszStr, pszDmiBIOSReleaseDate); 922 SETSTRING(pBIOSInf->u8Release, pszDmiBIOSReleaseDate); 918 923 pBIOSInf->u8ROMSize = 1; /* 128K */ 919 924 pBIOSInf->u64Characteristics = RT_BIT(4) /* ISA is supported */ … … 940 945 pSystemInf->header.u8Length = sizeof(*pSystemInf); 941 946 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); 950 951 951 952 RTUUID uuid; … … 965 966 pSystemInf->u8WakeupType = 6; /* Power Switch */ 966 967 pSystemInf->u8SKUNumber = 0; 967 pSystemInf->u8Family = iStrNr++; 968 STRCPY(pszStr, pszDmiSystemFamily); 968 SETSTRING(pSystemInf->u8Family, pszDmiSystemFamily); 969 969 *pszStr++ = '\0'; 970 970 … … 975 975 pEndOfTable->u16Handle = 0xFFFF; 976 976 977 /* If more fields are added here, fix the size check in S TRCPY*/978 979 #undef S TRCPY977 /* If more fields are added here, fix the size check in SETSTRING */ 978 979 #undef SETSTRING 980 980 #undef READCFG 981 981
Note:
See TracChangeset
for help on using the changeset viewer.