VirtualBox

Changeset 33271 in vbox for trunk


Ignore:
Timestamp:
Oct 20, 2010 4:02:57 PM (14 years ago)
Author:
vboxsync
Message:

Storage/VDI: Make the code dealing with comments bullet-proof, including the case where the image doesn't have the zero termination.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp

    r33182 r33271  
    16681668    {
    16691669        char *pszTmp = getImageComment(&pImage->Header);
    1670         size_t cb = strlen(pszTmp);
     1670        /* Make this foolproof even if the image doesn't have the zero
     1671         * termination. With some luck the repaired header will be saved. */
     1672        size_t cb = RTStrNLen(pszTmp, VDI_IMAGE_COMMENT_SIZE);
     1673        if (cb == VDI_IMAGE_COMMENT_SIZE)
     1674        {
     1675            pszTmp[VDI_IMAGE_COMMENT_SIZE-1] = '\0';
     1676            cb--;
     1677        }
    16711678        if (cb < cbComment)
    16721679        {
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