VirtualBox

Changeset 93891 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Feb 22, 2022 6:08:39 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
150110
Message:

Main: Guest Properties: improved property name and value validation, bugref:10185.

This commit also prevents guest properties loss if they were set while VM was running.

Location:
trunk/src/VBox/Main
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r93835 r93891  
    53205320        </desc>
    53215321      </param>
     5322      <param name="fWasDeleted" type="boolean" dir="in">
     5323        <desc>
     5324          The flag which indicates if property was deleted.
     5325        </desc>
     5326      </param>
    53225327    </method>
    53235328
  • trunk/src/VBox/Main/include/MachineImpl.h

    r93548 r93891  
    12341234                              const com::Utf8Str &aValue,
    12351235                              LONG64 aTimestamp,
    1236                               const com::Utf8Str &aFlags);
     1236                              const com::Utf8Str &aFlags,
     1237                              BOOL fWasDeleted);
    12371238    HRESULT lockMedia();
    12381239    HRESULT unlockMedia();
     
    13901391                              const com::Utf8Str &aValue,
    13911392                              LONG64 aTimestamp,
    1392                               const com::Utf8Str &aFlags);
     1393                              const com::Utf8Str &aFlags,
     1394                              BOOL fWasDeleted);
    13931395    HRESULT lockMedia();
    13941396    HRESULT unlockMedia();
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r93859 r93891  
    18491849                                                        value.raw(),
    18501850                                                        pCBData->u64Timestamp,
    1851                                                         flags.raw());
     1851                                                        flags.raw(),
     1852                                                        !pCBData->pcszValue);
    18521853    if (SUCCEEDED(hrc))
    18531854    {
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r93639 r93891  
    56555655    ReturnComNotImplemented();
    56565656#else // VBOX_WITH_GUEST_PROPS
     5657    AssertReturn(RT_SUCCESS(GuestPropValidateName(aProperty.c_str(), (uint32_t)aProperty.length() + 1 /* '\0' */)), E_INVALIDARG);
     5658    AssertReturn(RT_SUCCESS(GuestPropValidateValue(aValue.c_str(), (uint32_t)aValue.length() + 1  /* '\0' */)), E_INVALIDARG);
     5659
    56575660    HRESULT rc = i_setGuestPropertyToVM(aProperty, aValue, aFlags, /* fDelete = */ false);
    56585661    if (rc == E_ACCESSDENIED)
     
    57375740        GuestPropWriteFlags(it->second.mFlags, szFlags);
    57385741        aFlags[i] = Utf8Str(szFlags);
     5742
     5743        AssertReturn(RT_SUCCESS(GuestPropValidateName(aNames[i].c_str(), (uint32_t)aNames[i].length() + 1 /* '\0' */)), E_INVALIDARG);
     5744        AssertReturn(RT_SUCCESS(GuestPropValidateValue(aValues[i].c_str(), (uint32_t)aValues[i].length() + 1 /* '\0' */)), E_INVALIDARG);
    57395745    }
    57405746
     
    1357213578        else
    1357313579            aFlags[i] = "";
     13580
     13581        AssertReturn(RT_SUCCESS(GuestPropValidateName(aNames[i].c_str(), (uint32_t)aNames[i].length() + 1 /* '\0' */)), E_INVALIDARG);
     13582        AssertReturn(RT_SUCCESS(GuestPropValidateValue(aValues[i].c_str(), (uint32_t)aValues[i].length() + 1 /* '\0' */)), E_INVALIDARG);
    1357413583    }
    1357513584    return S_OK;
     
    1358213591                                          const com::Utf8Str &aValue,
    1358313592                                          LONG64 aTimestamp,
    13584                                           const com::Utf8Str &aFlags)
     13593                                          const com::Utf8Str &aFlags,
     13594                                          BOOL fWasDeleted)
    1358513595{
    1358613596    LogFlowThisFunc(("\n"));
     
    1361113621        mHWData.backup();
    1361213622
    13613         bool fDelete = !aValue.length();
    1361413623        HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.find(aName);
    1361513624        if (it != mHWData->mGuestProperties.end())
    1361613625        {
    13617             if (!fDelete)
     13626            if (!fWasDeleted)
    1361813627            {
    1361913628                it->second.strValue   = aValue;
     
    1362613635            mData->mGuestPropertiesModified = TRUE;
    1362713636        }
    13628         else if (!fDelete)
     13637        else if (!fWasDeleted)
    1362913638        {
    1363013639            HWData::GuestProperty prop;
     
    1504615055                                   const com::Utf8Str &aValue,
    1504715056                                   LONG64 aTimestamp,
    15048                                    const com::Utf8Str &aFlags)
     15057                                   const com::Utf8Str &aFlags,
     15058                                   BOOL fWasDeleted)
    1504915059{
    1505015060    NOREF(aName);
     
    1505215062    NOREF(aTimestamp);
    1505315063    NOREF(aFlags);
     15064    NOREF(fWasDeleted);
    1505415065    ReturnComNotImplemented();
    1505515066}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette