Index: trunk/src/VBox/Devices/Storage/DevATA.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/DevATA.cpp	(revision 15845)
+++ trunk/src/VBox/Devices/Storage/DevATA.cpp	(revision 15846)
@@ -97,4 +97,10 @@
 #define ATA_EVENT_STATUS_MEDIA_CHANGED          3    /**< medium was removed + new medium was inserted */
 
+/**
+ * Length of the configurable VPD data (without termination)
+ */
+#define ATA_SERIAL_NUMBER_LENGTH     20
+#define ATA_FIRMWARE_REVISION_LENGTH  8
+#define ATA_MODEL_NUMBER_LENGTH      40
 
 /*******************************************************************************
@@ -276,12 +282,12 @@
 
     /** The serial numnber to use for IDENTIFY DEVICE commands. */
-    int8_t                          abSerialNumber[20];
+    char                                achSerialNumber[ATA_SERIAL_NUMBER_LENGTH+1];
     /** The firmware revision to use for IDENTIFY DEVICE commands. */
-    int8_t                          abFirmwareRevision[8];
+    char                                achFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH+1];
     /** The model number to use for IDENTIFY DEVICE commands. */
-    int8_t                          abModelNumber[40];
+    char                                achModelNumber[ATA_MODEL_NUMBER_LENGTH+1];
 
 #if HC_ARCH_BITS == 64
-    uint32_t                        Alignment1;
+    uint32_t                            Alignment3[2];
 #endif
 } ATADevState;
@@ -1107,10 +1113,10 @@
     p[5] = RT_H2LE_U16(512);
     p[6] = RT_H2LE_U16(s->PCHSGeometry.cSectors);
-    ataPadString((uint8_t *)(p + 10), (const char *)s->abSerialNumber, 20); /* serial number */
+    ataPadString((uint8_t *)(p + 10), s->achSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */
     p[20] = RT_H2LE_U16(3); /* XXX: retired, cache type */
     p[21] = RT_H2LE_U16(512); /* XXX: retired, cache size in sectors */
     p[22] = RT_H2LE_U16(0); /* ECC bytes per sector */
-    ataPadString((uint8_t *)(p + 23), (const char *)s->abFirmwareRevision, 8); /* firmware version */
-    ataPadString((uint8_t *)(p + 27), (const char *)s->abModelNumber, 40); /* model */
+    ataPadString((uint8_t *)(p + 23), s->achFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */
+    ataPadString((uint8_t *)(p + 27), s->achModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */
 #if ATA_MAX_MULT_SECTORS > 1
     p[47] = RT_H2LE_U16(0x8000 | ATA_MAX_MULT_SECTORS);
@@ -1213,9 +1219,9 @@
     /* Removable CDROM, 50us response, 12 byte packets */
     p[0] = RT_H2LE_U16(2 << 14 | 5 << 8 | 1 << 7 | 2 << 5 | 0 << 0);
-    ataPadString((uint8_t *)(p + 10), (const char *)s->abSerialNumber, 20); /* serial number */
+    ataPadString((uint8_t *)(p + 10), s->achSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */
     p[20] = RT_H2LE_U16(3); /* XXX: retired, cache type */
     p[21] = RT_H2LE_U16(512); /* XXX: retired, cache size in sectors */
-    ataPadString((uint8_t *)(p + 23), (const char *)s->abFirmwareRevision, 8); /* firmware version */
-    ataPadString((uint8_t *)(p + 27), (const char *)s->abModelNumber, 40); /* model */
+    ataPadString((uint8_t *)(p + 23), s->achFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */
+    ataPadString((uint8_t *)(p + 27), s->achModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */
     p[49] = RT_H2LE_U16(1 << 11 | 1 << 9 | 1 << 8); /* DMA and LBA supported */
     p[50] = RT_H2LE_U16(1 << 14);  /* No drive specific standby timer minimum */
@@ -6298,5 +6304,5 @@
                         { "SecondaryMaster", "SecondarySlave" }
                     };
-                    char aSerial[20];
+                    char aSerial[ATA_SERIAL_NUMBER_LENGTH+1];
                     RTUUID Uuid;
                     if (pIf->pDrvBlock)
@@ -6314,10 +6320,10 @@
                     else
                         RTStrPrintf(aSerial, sizeof(aSerial), "VB%08x-%08x", Uuid.au32[0], Uuid.au32[3]);
-                    strncpy((char *)pIf->abSerialNumber, aSerial, 20);
-                    strncpy((char *)pIf->abFirmwareRevision, "1.0", 8);
+                    strncpy(pIf->achSerialNumber, aSerial, sizeof(pIf->achSerialNumber));
+                    strncpy(pIf->achFirmwareRevision, "1.0", sizeof(pIf->achSerialNumber));
                     if (pIf->fATAPI)
-                        strncpy((char *)pIf->abModelNumber, "VBOX CD-ROM", 40);
+                        strncpy(pIf->achModelNumber, "VBOX CD-ROM", sizeof(pIf->achModelNumber));
                     else
-                        strncpy((char *)pIf->abModelNumber, "VBOX HARDDISK", 40);
+                        strncpy(pIf->achModelNumber, "VBOX HARDDISK", sizeof(pIf->achModelNumber));
 
                     /* Check if the user provided some values to overwrite. */
@@ -6325,48 +6331,31 @@
                     if (pCfgNode)
                     {
-                        char *pszCFGMValue;
-
-                        rc = CFGMR3QueryStringAlloc(pCfgNode, "SerialNumber", &pszCFGMValue);
-                        if (RT_SUCCESS(rc))
+                        rc = CFGMR3QueryString(pCfgNode, "SerialNumber", pIf->achSerialNumber, sizeof(pIf->achSerialNumber));
+                        if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
                         {
-                            /* Check length of the serial number. It shouldn't be longer than 20 bytes. */
-                            if (strlen(pszCFGMValue) > 20)
-                                return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
-                                            N_("PIIX3 configuration error: \"SerialNumber\" is longer than 20 bytes"));
-                            /* Copy the data over. */
-                            strncpy((char *)pIf->abSerialNumber, pszCFGMValue, 20);
-                            MMR3HeapFree(pszCFGMValue);
+                            return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
+                                        N_("PIIX3 configuration error: \"SerialNumber\" is longer than 20 bytes"));
                         }
-                        else if (rc != VERR_CFGM_VALUE_NOT_FOUND)
+                        else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND))
                             return PDMDEV_SET_ERROR(pDevIns, rc,
                                         N_("PIIX3 configuration error: failed to read \"SerialNumber\" as string"));
 
-                        rc = CFGMR3QueryStringAlloc(pCfgNode, "FirmwareRevision", &pszCFGMValue);
-                        if (RT_SUCCESS(rc))
+                        rc = CFGMR3QueryString(pCfgNode, "FirmwareRevision", pIf->achFirmwareRevision, sizeof(pIf->achFirmwareRevision));
+                        if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
                         {
-                            /* Check length of the firmware revision. It shouldn't be longer than 8 bytes. */
-                            if (strlen(pszCFGMValue) > 8)
-                                return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
-                                            N_("PIIX3 configuration error: \"FirmwareRevision\" is longer than 8 bytes"));
-                            /* Copy the data over. */
-                            strncpy((char *)pIf->abFirmwareRevision, pszCFGMValue, 8);
-                            MMR3HeapFree(pszCFGMValue);
+                            return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
+                                        N_("PIIX3 configuration error: \"FirmwareRevision\" is longer than 8 bytes"));
                         }
-                        else if (rc != VERR_CFGM_VALUE_NOT_FOUND)
+                        else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND))
                             return PDMDEV_SET_ERROR(pDevIns, rc,
                                         N_("PIIX3 configuration error: failed to read \"FirmwareRevision\" as string"));
 
-                        rc = CFGMR3QueryStringAlloc(pCfgNode, "ModelNumber", &pszCFGMValue);
-                        if (RT_SUCCESS(rc))
+                        rc = CFGMR3QueryString(pCfgNode, "ModelNumber", pIf->achModelNumber, sizeof(pIf->achModelNumber));
+                        if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
                         {
-                            /* Check length of the model number. It shouldn't be longer than 40 bytes. */
-                            if (strlen(pszCFGMValue) > 40)
-                                return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
-                                            N_("PIIX3 configuration error: \"ModelNumber\" is longer than 40 bytes"));
-                            /* Copy the data over. */
-                            strncpy((char *)pIf->abModelNumber, pszCFGMValue, 40);
-                            MMR3HeapFree(pszCFGMValue);
+                            return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
+                                       N_("PIIX3 configuration error: \"ModelNumber\" is longer than 40 bytes"));
                         }
-                        else if (rc != VERR_CFGM_VALUE_NOT_FOUND)
+                        else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND))
                             return PDMDEV_SET_ERROR(pDevIns, rc,
                                         N_("PIIX3 configuration error: failed to read \"ModelNumber\" as string"));
Index: trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp
===================================================================
--- trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp	(revision 15845)
+++ trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp	(revision 15846)
@@ -698,10 +698,10 @@
     GEN_CHECK_OFF(ATADevState, pControllerR0);
     GEN_CHECK_OFF(ATADevState, pControllerRC);
-    GEN_CHECK_OFF(ATADevState, abSerialNumber);
-    GEN_CHECK_OFF(ATADevState, abSerialNumber[19]);
-    GEN_CHECK_OFF(ATADevState, abFirmwareRevision);
-    GEN_CHECK_OFF(ATADevState, abFirmwareRevision[7]);
-    GEN_CHECK_OFF(ATADevState, abModelNumber);
-    GEN_CHECK_OFF(ATADevState, abModelNumber[39]);
+    GEN_CHECK_OFF(ATADevState, achSerialNumber);
+    GEN_CHECK_OFF(ATADevState, achSerialNumber[ATA_SERIAL_NUMBER_LENGTH]);
+    GEN_CHECK_OFF(ATADevState, achFirmwareRevision);
+    GEN_CHECK_OFF(ATADevState, achFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH]);
+    GEN_CHECK_OFF(ATADevState, achModelNumber);
+    GEN_CHECK_OFF(ATADevState, achModelNumber[ATA_MODEL_NUMBER_LENGTH]);
     GEN_CHECK_SIZE(ATATransferRequest);
     GEN_CHECK_OFF(ATATransferRequest, iIf);
@@ -1143,10 +1143,10 @@
     GEN_CHECK_OFF(AHCIPort, fNotificationSend);
     GEN_CHECK_OFF(AHCIPort, fPortReset);
-    GEN_CHECK_OFF(AHCIPort, abSerialNumber);
-    GEN_CHECK_OFF(AHCIPort, abSerialNumber[19]);
-    GEN_CHECK_OFF(AHCIPort, abFirmwareRevision);
-    GEN_CHECK_OFF(AHCIPort, abFirmwareRevision[7]);
-    GEN_CHECK_OFF(AHCIPort, abModelNumber);
-    GEN_CHECK_OFF(AHCIPort, abModelNumber[39]);
+    GEN_CHECK_OFF(AHCIPort, achSerialNumber);
+    GEN_CHECK_OFF(AHCIPort, achSerialNumber[AHCI_SERIAL_NUMBER_LENGTH]); /* One additional byte for the termination.*/
+    GEN_CHECK_OFF(AHCIPort, achFirmwareRevision);
+    GEN_CHECK_OFF(AHCIPort, achFirmwareRevision[AHCI_FIRMWARE_REVISION_LENGTH]); /* One additional byte for the termination.*/
+    GEN_CHECK_OFF(AHCIPort, achModelNumber);
+    GEN_CHECK_OFF(AHCIPort, achModelNumber[AHCI_MODEL_NUMBER_LENGTH]); /* One additional byte for the termination.*/
 
     GEN_CHECK_SIZE(AHCI);
