VirtualBox

Changeset 51015 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Apr 9, 2014 2:31:21 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
93217
Message:

oops

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/shflsvc.h

    r51014 r51015  
    205205
    206206/**
    207  * Validates a HGCM string output parameter.
     207 * Validates a HGCM string parameter.
    208208 *
    209209 * @returns true if valid, false if not.
     
    212212 * @param   cbBuf       The buffer size from the parameter.
    213213 */
    214 DECLINLINE(bool) ShflStringIsValidOut(PCSHFLSTRING pString, uint32_t cbBuf)
     214DECLINLINE(bool) ShflStringIsValid(PCSHFLSTRING pString, uint32_t cbBuf)
    215215{
    216216    if (RT_UNLIKELY(cbBuf <= RT_UOFFSETOF(SHFLSTRING, String)))
     
    220220    if (RT_UNLIKELY(pString->u16Length >= pString->u16Size))
    221221        return false;
     222    /** @todo r=bird: Check that u16Length is a multiple of two if UTF-16 input? */
     223    /** @todo r=bird: Do we require the string to have a NUL terminator char, if
     224     *        so check for it!! (Just had a problem with too small (/2) u16Length
     225     *        and code behaving incorrectly because it worked up to the terminator
     226     *        instead of the length.) */
     227    /** @todo r=bird: Who checks for valid UTF-8 encoding of strings? */
    222228    return true;
    223229}
    224230
    225231/**
    226  * Validates a HGCM string input parameter.
    227  *
    228  * @returns true if valid, false if not.
    229  *
    230  * @param   pString     The string buffer pointer.
    231  * @param   cbBuf       The buffer size from the parameter.
    232  * @param   fUtf8Not16  Set if UTF-8 encoding, clear if UTF-16 encoding.
    233  */
    234 DECLINLINE(bool) ShflStringIsValidIn(PCSHFLSTRING pString, uint32_t cbBuf, bool fUtf8Not16)
    235 {
    236     int rc;
    237     if (RT_UNLIKELY(cbBuf <= RT_UOFFSETOF(SHFLSTRING, String)))
    238         return false;
    239     if (RT_UNLIKELY((uint32_t)pString->u16Size + RT_UOFFSETOF(SHFLSTRING, String) > cbBuf))
    240         return false;
    241     if (fUtf8Not16)
    242     {
    243         /* UTF-8: */
    244         if (RT_UNLIKELY(pString->u16Length >= pString->u16Size))
    245             return false;
    246         rc = RTStrValidateEncodingEx((const char *)&pString->String.utf8[0], pString->u16Length + 1,
    247                                      RTSTR_VALIDATE_ENCODING_EXACT_LENGTH | RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
    248     }
    249     else
    250     {
    251         /* UTF-16: */
    252         if (RT_UNLIKELY(pString->u16Length & 1))
    253             return false;
    254         if (RT_UNLIKELY((uint32_t)sizeof(RTUTF16) + pString->u16Length > pString->u16Size))
    255             return false;
    256         rc = RTUtf16ValidateEncodingEx(&pString->String.ucs2[0], pString->u16Length / 2 + 1,
    257                                        RTSTR_VALIDATE_ENCODING_EXACT_LENGTH | RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
    258     }
    259     if (RT_FAILURE(rc))
    260         return false;
    261     return true;
    262 }
    263 
    264 /**
    265  * Validates an optional HGCM string input parameter.
     232 * Validates an optional HGCM string parameter.
    266233 *
    267234 * @returns true if valid, false if not.
     
    269236 * @param   pString     The string buffer pointer. Can be NULL.
    270237 * @param   cbBuf       The buffer size from the parameter.
    271  * @param   fUtf8Not16  Set if UTF-8 encoding, clear if UTF-16 encoding.
    272  */
    273 DECLINLINE(bool) ShflStringIsValidOrNullIn(PCSHFLSTRING pString, uint32_t cbBuf, bool fUtf8Not16)
     238 */
     239DECLINLINE(bool) ShflStringIsValidOrNull(PCSHFLSTRING pString, uint32_t cbBuf)
    274240{
    275241    if (pString)
    276         return ShflStringIsValidIn(pString, cbBuf, fUtf8Not16);
     242        return ShflStringIsValid(pString, cbBuf);
    277243    if (RT_UNLIKELY(cbBuf > 0))
    278244        return false;
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