VirtualBox

Changeset 73804 in vbox


Ignore:
Timestamp:
Aug 21, 2018 4:21:23 PM (6 years ago)
Author:
vboxsync
Message:

Main: bugref:9075: added check into the IMachine::SetExtraData and IVirtualBox::SetExtraData to avoid the presence of non-ASCII and non printable characters in the key

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

Legend:

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

    r73768 r73804  
    27452745
    27462746        <note>
     2747          Key must contain only printable ASCII characters.
     2748        </note>
     2749        <note>
    27472750          Before performing the actual data change, this method will ask all
    27482751          registered event listener using the
     
    27662769        <result name="E_ACCESSDENIED">
    27672770          Modification request refused.
     2771        </result>
     2772        <result name="E_INVALIDARG">
     2773          Key contains invalid characters.
    27682774        </result>
    27692775
     
    69586964
    69596965        <note>
     6966          Key must contain only printable ASCII characters.
     6967        </note>
     6968        <note>
    69606969          Before performing the actual data change, this method will ask all
    69616970          registered listeners using the
     
    69816990        <result name="VBOX_E_XML_ERROR">
    69826991          Could not parse the settings file.
     6992        </result>
     6993        <result name="E_INVALIDARG">
     6994          Key contains invalid characters.
    69836995        </result>
    69846996
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r73744 r73804  
    6969#include <iprt/sha.h>
    7070#include <iprt/string.h>
     71#include <iprt/ctype.h>
    7172
    7273#include <VBox/com/array.h>
     
    50725073HRESULT Machine::setExtraData(const com::Utf8Str &aKey, const com::Utf8Str &aValue)
    50735074{
     5075    /* Because non-ASCII characters in aKey have caused problems in the settings
     5076     * they are rejected unless the key should be deleted. */
     5077    if (!aValue.isEmpty())
     5078    {
     5079        for (int i = 0; i < aKey.length(); ++i)
     5080        {
     5081            char ch = aKey[i];
     5082            if (!RTLocCIsPrint(ch))
     5083                return E_INVALIDARG;
     5084        }
     5085    }
     5086
    50745087    Utf8Str strOldValue;            // empty
    50755088
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r73716 r73804  
    3232#include <iprt/uuid.h>
    3333#include <iprt/cpp/xml.h>
     34#include <iprt/ctype.h>
    3435
    3536#include <VBox/com/com.h>
     
    20682069                                 const com::Utf8Str &aValue)
    20692070{
    2070 
    20712071    Utf8Str strKey(aKey);
    20722072    Utf8Str strValue(aValue);
    20732073    Utf8Str strOldValue;            // empty
    20742074    HRESULT rc = S_OK;
     2075
     2076    /* Because non-ASCII characters in aKey have caused problems in the settings
     2077     * they are rejected unless the key should be deleted. */
     2078    if (!strValue.isEmpty())
     2079    {
     2080        for (int i = 0; i < strKey.length(); ++i)
     2081        {
     2082            char ch = strKey[i];
     2083            if (!RTLocCIsPrint(ch))
     2084                return E_INVALIDARG;
     2085        }
     2086    }
    20752087
    20762088    // locking note: we only hold the read lock briefly to look up the old value,
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