VirtualBox

Changeset 95325 in vbox for trunk/src/VBox/Main/xml


Ignore:
Timestamp:
Jun 21, 2022 2:18:21 PM (3 years ago)
Author:
vboxsync
Message:

Main/xml: Removed unnecessary string resizing in MachineConfigFile::readGuestProperties, as the string will be freed after the push_back anyway. Added @todo about generating invalid UTF-8. bugref:10185

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/Settings.cpp

    r95229 r95325  
    46474647    {
    46484648        GuestProperty prop;
    4649         int rc;
    46504649
    46514650        pelmProp->getAttributeValue("name", prop.strName);
     
    46584657         * placing it to local cache. */
    46594658
    4660         rc = GuestPropValidateName(prop.strName.c_str(), (uint32_t)prop.strName.length() + 1  /* '\0' */);
     4659        int rc = GuestPropValidateName(prop.strName.c_str(), (uint32_t)prop.strName.length() + 1  /* '\0' */);
    46614660        if (RT_FAILURE(rc))
    46624661        {
     
    46734672
    46744673            /* In order to pass validation, guest property value length (including '\0') in bytes
    4675              * should be less than GUEST_PROP_MAX_VALUE_LEN. Reallocate it to corresponding size. */
    4676             rc = prop.strValue.reserveNoThrow(GUEST_PROP_MAX_VALUE_LEN - 1);
    4677             if (RT_SUCCESS(rc))
    4678             {
    4679                 prop.strValue.mutableRaw()[GUEST_PROP_MAX_VALUE_LEN - 2] = '\0';
    4680                 prop.strValue.jolt();
    4681             }
    4682             else
    4683             {
    4684                 LogRel(("WARNING: Unable to truncate guest property '%s' valuem rc=%Rrc. Guest property value will be skipped.\n",
    4685                         prop.strName.c_str(), rc));
    4686                 continue;
    4687             }
     4674             * should be less than GUEST_PROP_MAX_VALUE_LEN. Chop it down to an appropriate length. */
     4675            /** @todo r=bird: Should add a RTCString method for this, as this may create a
     4676             *        invalid UTF-8 encoding if we chop up a UTF-8 sequence. */
     4677            Assert(prop.strValue.length() + 1 >= GUEST_PROP_MAX_VALUE_LEN);
     4678            prop.strValue.mutableRaw()[GUEST_PROP_MAX_VALUE_LEN - 2] = '\0';
     4679            prop.strValue.jolt();
    46884680        }
    46894681        else if (RT_FAILURE(rc))
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