VirtualBox

Changeset 51014 in vbox


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

Temporarily renamed iprt/x509.h to iprt/x509-branch-collision.h to avoid trouble when merging branch code later.

Location:
trunk
Files:
3 edited
1 moved

Legend:

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

    r44528 r51014  
    205205
    206206/**
    207  * Validates a HGCM string parameter.
     207 * Validates a HGCM string output parameter.
    208208 *
    209209 * @returns true if valid, false if not.
     
    212212 * @param   cbBuf       The buffer size from the parameter.
    213213 */
    214 DECLINLINE(bool) ShflStringIsValid(PCSHFLSTRING pString, uint32_t cbBuf)
     214DECLINLINE(bool) ShflStringIsValidOut(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? */
    228222    return true;
    229223}
    230224
    231225/**
    232  * Validates an optional HGCM string parameter.
     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 */
     234DECLINLINE(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.
    233266 *
    234267 * @returns true if valid, false if not.
     
    236269 * @param   pString     The string buffer pointer. Can be NULL.
    237270 * @param   cbBuf       The buffer size from the parameter.
    238  */
    239 DECLINLINE(bool) ShflStringIsValidOrNull(PCSHFLSTRING pString, uint32_t cbBuf)
     271 * @param   fUtf8Not16  Set if UTF-8 encoding, clear if UTF-16 encoding.
     272 */
     273DECLINLINE(bool) ShflStringIsValidOrNullIn(PCSHFLSTRING pString, uint32_t cbBuf, bool fUtf8Not16)
    240274{
    241275    if (pString)
    242         return ShflStringIsValid(pString, cbBuf);
     276        return ShflStringIsValidIn(pString, cbBuf, fUtf8Not16);
    243277    if (RT_UNLIKELY(cbBuf > 0))
    244278        return false;
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r50904 r51014  
    4747#include <VBox/settings.h>
    4848
    49 #include <iprt/x509.h>
     49#include <iprt/x509-branch-collision.h>
    5050#include <set>
    5151
  • trunk/src/VBox/Runtime/common/checksum/x509.cpp

    r50954 r51014  
    3030*******************************************************************************/
    3131#include "internal/iprt.h"
    32 #include <iprt/x509.h>
     32#include <iprt/x509-branch-collision.h>
    3333
    3434#include <iprt/assert.h>
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