- Timestamp:
- Aug 27, 2009 1:52:56 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 51548
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/CFGM.cpp
r22346 r22526 549 549 550 550 case CFGMVALUETYPE_STRING: 551 *pcb = pLeaf->Value.String.c ch;551 *pcb = pLeaf->Value.String.cb; 552 552 break; 553 553 … … 638 638 if (pLeaf->enmType == CFGMVALUETYPE_STRING) 639 639 { 640 if (cchString >= pLeaf->Value.String.cch) 640 size_t cbSrc = pLeaf->Value.String.cb; 641 if (cchString >= cbSrc) 641 642 { 642 memcpy(pszString, pLeaf->Value.String.psz, pLeaf->Value.String.cch);643 memset(pszString + pLeaf->Value.String.cch, 0, cchString - pLeaf->Value.String.cch);643 memcpy(pszString, pLeaf->Value.String.psz, cbSrc); 644 memset(pszString + cbSrc, 0, cchString - cbSrc); 644 645 } 645 646 else … … 671 672 if (pLeaf->enmType == CFGMVALUETYPE_STRING) 672 673 { 673 if (cchString >= pLeaf->Value.String.cch) 674 size_t cbSrc = pLeaf->Value.String.cb; 675 if (cchString >= cbSrc) 674 676 { 675 memcpy(pszString, pLeaf->Value.String.psz, pLeaf->Value.String.cch);676 memset(pszString + pLeaf->Value.String.cch, 0, cchString - pLeaf->Value.String.cch);677 memcpy(pszString, pLeaf->Value.String.psz, cbSrc); 678 memset(pszString + cbSrc, 0, cchString - cbSrc); 677 679 } 678 680 else … … 1535 1537 MMR3HeapFree(pLeaf->Value.String.psz); 1536 1538 pLeaf->Value.String.psz = NULL; 1537 pLeaf->Value.String.c ch= 0;1539 pLeaf->Value.String.cb = 0; 1538 1540 break; 1539 1541 … … 1574 1576 * @param pszName Value name. 1575 1577 * @param pszString The value. 1576 */ 1578 */ 1577 1579 VMMR3DECL(int) CFGMR3InsertString(PCFGMNODE pNode, const char *pszName, const char *pszString) 1578 1580 { … … 1583 1585 * Allocate string object first. 1584 1586 */ 1585 size_t c chString = strlen(pszString) + 1;1586 char *pszStringCopy = (char *)MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_STRING, RT_ALIGN_Z(cchString, 16));1587 size_t cbString = strlen(pszString) + 1; 1588 char *pszStringCopy = (char *)MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_STRING, cbString); 1587 1589 if (pszStringCopy) 1588 1590 { 1589 memcpy(pszStringCopy, pszString, c chString);1591 memcpy(pszStringCopy, pszString, cbString); 1590 1592 1591 1593 /* … … 1598 1600 pLeaf->enmType = CFGMVALUETYPE_STRING; 1599 1601 pLeaf->Value.String.psz = pszStringCopy; 1600 pLeaf->Value.String.c ch = cchString;1602 pLeaf->Value.String.cb = cbString; 1601 1603 } 1602 1604 else … … 1614 1616 1615 1617 /** 1616 * Same as CFGMR3InsertString except the string value given in RTStrPrintfV 1617 * fashion. 1618 * 1618 * Same as CFGMR3InsertString except the string value given in RTStrPrintfV 1619 * fashion. 1620 * 1619 1621 * @returns VBox status code. 1620 1622 * @param pNode Parent node. … … 1643 1645 pLeaf->enmType = CFGMVALUETYPE_STRING; 1644 1646 pLeaf->Value.String.psz = pszString; 1645 pLeaf->Value.String.c ch = strlen(pszString);1647 pLeaf->Value.String.cb = strlen(pszString) + 1; 1646 1648 } 1647 1649 else … … 1659 1661 1660 1662 /** 1661 * Same as CFGMR3InsertString except the string value given in RTStrPrintf 1662 * fashion. 1663 * 1663 * Same as CFGMR3InsertString except the string value given in RTStrPrintf 1664 * fashion. 1665 * 1664 1666 * @returns VBox status code. 1665 1667 * @param pNode Parent node. … … 1680 1682 /** 1681 1683 * Same as CFGMR3InsertString except the string value given as a UTF-16 string. 1682 * 1684 * 1683 1685 * @returns VBox status code. 1684 1686 * @param pNode Parent node. … … 1718 1720 * Allocate string object first. 1719 1721 */ 1720 void *pvCopy = MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_STRING, RT_ALIGN_Z(cbBytes, 16));1722 void *pvCopy = MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_STRING, cbBytes); 1721 1723 if (pvCopy || !cbBytes) 1722 1724 { … … 2465 2467 VMMR3DECL(int) CFGMR3QueryStringAlloc(PCFGMNODE pNode, const char *pszName, char **ppszString) 2466 2468 { 2467 size_t c ch;2468 int rc = CFGMR3QuerySize(pNode, pszName, &c ch);2469 if (RT_SUCCESS(rc)) 2470 { 2471 char *pszString = (char *)MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_USER, c ch);2469 size_t cbString; 2470 int rc = CFGMR3QuerySize(pNode, pszName, &cbString); 2471 if (RT_SUCCESS(rc)) 2472 { 2473 char *pszString = (char *)MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_USER, cbString); 2472 2474 if (pszString) 2473 2475 { 2474 rc = CFGMR3QueryString(pNode, pszName, pszString, c ch);2476 rc = CFGMR3QueryString(pNode, pszName, pszString, cbString); 2475 2477 if (RT_SUCCESS(rc)) 2476 2478 *ppszString = pszString; … … 2497 2499 VMMR3DECL(int) CFGMR3QueryStringAllocDef(PCFGMNODE pNode, const char *pszName, char **ppszString, const char *pszDef) 2498 2500 { 2499 size_t c ch;2500 int rc = CFGMR3QuerySize(pNode, pszName, &c ch);2501 size_t cbString; 2502 int rc = CFGMR3QuerySize(pNode, pszName, &cbString); 2501 2503 if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT) 2502 2504 { 2503 c ch= strlen(pszDef) + 1;2505 cbString = strlen(pszDef) + 1; 2504 2506 rc = VINF_SUCCESS; 2505 2507 } 2506 2508 if (RT_SUCCESS(rc)) 2507 2509 { 2508 char *pszString = (char *)MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_USER, c ch);2510 char *pszString = (char *)MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_USER, cbString); 2509 2511 if (pszString) 2510 2512 { 2511 rc = CFGMR3QueryStringDef(pNode, pszName, pszString, c ch, pszDef);2513 rc = CFGMR3QueryStringDef(pNode, pszName, pszString, cbString, pszDef); 2512 2514 if (RT_SUCCESS(rc)) 2513 2515 *ppszString = pszString; … … 2607 2609 2608 2610 case CFGMVALUETYPE_STRING: 2609 pHlp->pfnPrintf(pHlp, " %-*s <string> = \"%s\" (c ch=%d)\n", (int)cchMax, pLeaf->szName, pLeaf->Value.String.psz, pLeaf->Value.String.cch);2611 pHlp->pfnPrintf(pHlp, " %-*s <string> = \"%s\" (cb=%zu)\n", (int)cchMax, pLeaf->szName, pLeaf->Value.String.psz, pLeaf->Value.String.cb); 2610 2612 break; 2611 2613 2612 2614 case CFGMVALUETYPE_BYTES: 2613 pHlp->pfnPrintf(pHlp, " %-*s <bytes> = \"%.*Rhxs\" (cb=% d)\n", (int)cchMax, pLeaf->szName, pLeaf->Value.Bytes.cb, pLeaf->Value.Bytes.pau8, pLeaf->Value.Bytes.cb);2615 pHlp->pfnPrintf(pHlp, " %-*s <bytes> = \"%.*Rhxs\" (cb=%zu)\n", (int)cchMax, pLeaf->szName, pLeaf->Value.Bytes.cb, pLeaf->Value.Bytes.pau8, pLeaf->Value.Bytes.cb); 2614 2616 break; 2615 2617 -
trunk/src/VBox/VMM/CFGMInternal.h
r14070 r22526 49 49 { 50 50 /** Length of string. (In bytes, including the terminator.) */ 51 size_t c ch;51 size_t cb; 52 52 /** Pointer to the string. */ 53 53 char *psz;
Note:
See TracChangeset
for help on using the changeset viewer.