VirtualBox

Changeset 40091 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Feb 13, 2012 10:14:00 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
76231
Message:

Runtime/strings: add Utf-8 and Utf-16 sanitising to a white list of characters. Do not validate the string encoding in advance.

Location:
trunk/src/VBox/Runtime/common/string
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/utf-16.cpp

    r40073 r40091  
    255255    AssertReturn(chReplacement && (unsigned)chReplacement < 128, -1);
    256256    /* Validate the encoding. */
    257     if (RT_FAILURE(RTUtf16CalcUtf8LenEx(pwsz, RTSTR_MAX, NULL)))
    258         return -1;
    259257    for (;;)
    260258    {
     
    262260        PCRTUNICP pCp;
    263261        PRTUTF16 pwszOld = pwsz;
    264         RTUtf16GetCpEx((PCRTUTF16 *)&pwsz, &Cp);
     262        if (RT_FAILURE(RTUtf16GetCpEx((PCRTUTF16 *)&pwsz, &Cp)))
     263            return -1;
    265264        if (!Cp)
    266265            break;
  • trunk/src/VBox/Runtime/common/string/utf-8.cpp

    r40073 r40091  
    356356    size_t cReplacements = 0;
    357357    AssertReturn(chReplacement && (unsigned)chReplacement < 128, -1);
    358     if (RT_FAILURE(RTStrValidateEncoding(psz)))
    359         return -1;
    360358    for (;;)
    361359    {
     
    363361        PCRTUNICP pCp;
    364362        char *pszOld = psz;
    365         RTStrGetCpEx((const char **)&psz, &Cp);
     363        if (RT_FAILURE(RTStrGetCpEx((const char **)&psz, &Cp)))
     364            return -1;
    366365        if (!Cp)
    367366            break;
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