VirtualBox

Changeset 21629 in vbox for trunk/src


Ignore:
Timestamp:
Jul 15, 2009 9:22:54 PM (15 years ago)
Author:
vboxsync
Message:

HostServices/GuestProperties: fix a todo

Location:
trunk/src/VBox/HostServices/GuestProperties
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/GuestProperties/service.cpp

    r21507 r21629  
    360360
    361361/**
    362  * Checking that the name passed by the guest fits our criteria for a
    363  * property name.
     362 * Check that a string fits our criteria for a property name.
    364363 *
    365364 * @returns IPRT status code
    366  * @param   pszName   the name passed by the guest
    367  * @param   cbName    the number of bytes pszName points to, including the
     365 * @param   pszName   the string to check, must be valid Utf8
     366 * @param   cbName    the number of bytes @a pszName points to, including the
    368367 *                    terminating '\0'
    369368 * @thread  HGCM
     
    372371{
    373372    LogFlowFunc(("cbName=%d\n", cbName));
    374 
    375     /*
    376      * Validate the name, checking that it's proper UTF-8 and has
    377      * a string terminator.
    378      */
    379373    int rc = VINF_SUCCESS;
    380374    if (RT_SUCCESS(rc) && (cbName < 2))
    381375        rc = VERR_INVALID_PARAMETER;
    382     if (RT_SUCCESS(rc))
    383         rc = RTStrValidateEncodingEx(pszName, RT_MIN(cbName, (uint32_t) MAX_NAME_LEN),
    384                                      RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
    385376    for (unsigned i = 0; RT_SUCCESS(rc) && i < cbName; ++i)
    386377        if (pszName[i] == '*' || pszName[i] == '?' || pszName[i] == '|')
     
    392383
    393384/**
    394  * Check that the data passed by the guest fits our criteria for the value of
    395  * a guest property.
     385 * Check a string fits our criteria for the value of a guest property.
    396386 *
    397387 * @returns IPRT status code
    398  * @param   pszValue  the value to store in the property
    399  * @param   cbValue   the number of bytes in the buffer pszValue points to
     388 * @param   pszValue  the string to check, must be valid Utf8
     389 * @param   cbValue   the length in bytes of @a pszValue, including the
     390 *                    terminator
    400391 * @thread  HGCM
    401392 */
     
    404395    LogFlowFunc(("cbValue=%d\n", cbValue));
    405396
    406     /*
    407      * Validate the value, checking that it's proper UTF-8 and has
    408      * a string terminator.
    409      */
    410397    int rc = VINF_SUCCESS;
    411398    if (RT_SUCCESS(rc) && cbValue == 0)
    412399        rc = VERR_INVALID_PARAMETER;
    413     if (RT_SUCCESS(rc))
    414         rc = RTStrValidateEncodingEx(pszValue, RT_MIN(cbValue, (uint32_t) MAX_VALUE_LEN),
    415                                      RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
    416400    if (RT_SUCCESS(rc))
    417401        LogFlow(("    pszValue=%s\n", cbValue > 0 ? pszValue : NULL));
     
    535519    LogFlowThisFunc(("\n"));
    536520    if (   cParms != 4  /* Hardcoded value as the next lines depend on it. */
    537         || RT_FAILURE (paParms[0].getPointer ((const void **) &pcszName, &cchName))    /* name */
    538         || RT_FAILURE (paParms[1].getPointer ((void **) &pchBuf, &cchBuf))    /* buffer */
     521        || RT_FAILURE (paParms[0].getString(&pcszName, &cchName))  /* name */
     522        || RT_FAILURE (paParms[1].getBuffer((void **) &pchBuf, &cchBuf))  /* buffer */
    539523       )
    540524        rc = VERR_INVALID_PARAMETER;
     
    619603    if (   RT_SUCCESS(rc)
    620604        && (   (cParms < 2) || (cParms > 3)  /* Hardcoded value as the next lines depend on it. */
    621             || RT_FAILURE(paParms[0].getPointer ((const void **) &pcszName,
    622                                                  &cchName)) /* name */
    623             || RT_FAILURE(paParms[1].getPointer ((const void **) &pcszValue,
    624                                                  &cchValue)) /* value */
     605            || RT_FAILURE(paParms[0].getString(&pcszName, &cchName))  /* name */
     606            || RT_FAILURE(paParms[1].getString(&pcszValue, &cchValue))  /* value */
    625607            || (   (3 == cParms)
    626                 && RT_FAILURE(paParms[2].getPointer ((const void **) &pcszFlags,
    627                                                      &cchFlags)) /* flags */
     608                && RT_FAILURE(paParms[2].getString(&pcszFlags, &cchFlags)) /* flags */
    628609               )
    629610           )
     
    715696     */
    716697    if (   (cParms != 1)  /* Hardcoded value as the next lines depend on it. */
    717         || RT_FAILURE(paParms[0].getPointer ((const void **) &pcszName,
    718                                              &cbName))  /* name */
     698        || RT_FAILURE(paParms[0].getString(&pcszName, &cbName))  /* name */
    719699       )
    720700        rc = VERR_INVALID_PARAMETER;
     
    777757    LogFlowThisFunc(("\n"));
    778758    if (   (cParms != 3)  /* Hardcoded value as the next lines depend on it. */
    779         || RT_FAILURE(paParms[0].getPointer ((const void **) &pcchPatterns,
    780                                              &cchPatterns))  /* patterns */
    781         || RT_FAILURE(paParms[1].getPointer ((void **) &pchBuf, &cchBuf))  /* return buffer */
     759        || RT_FAILURE(paParms[0].getString(&pcchPatterns, &cchPatterns))  /* patterns */
     760        || RT_FAILURE(paParms[1].getBuffer((void **) &pchBuf, &cchBuf))  /* return buffer */
    782761       )
    783762        rc = VERR_INVALID_PARAMETER;
     
    789768     */
    790769    char pszPatterns[MAX_PATTERN_LEN];
    791     if (NULL == pcchPatterns)
    792         pszPatterns[0] = '\0';
    793     else
    794     {
    795         for (unsigned i = 0; i < cchPatterns - 1; ++i)
    796             if (pcchPatterns[i] != '\0')
    797                 pszPatterns[i] = pcchPatterns[i];
    798             else
    799                 pszPatterns[i] = '|';
    800         pszPatterns[cchPatterns - 1] = '\0';
    801     }
     770    for (unsigned i = 0; i < cchPatterns - 1; ++i)
     771        if (pcchPatterns[i] != '\0')
     772            pszPatterns[i] = pcchPatterns[i];
     773        else
     774            pszPatterns[i] = '|';
     775    pszPatterns[cchPatterns - 1] = '\0';
    802776
    803777    /*
     
    885859    char *pchBuf;
    886860    uint32_t cchBuf;
    887     rc = paParms[2].getPointer((void **) &pchBuf, &cchBuf);
     861    rc = paParms[2].getBuffer((void **) &pchBuf, &cchBuf);
    888862    if (RT_SUCCESS(rc))
    889863    {
     
    936910    LogFlowThisFunc(("\n"));
    937911    if (   (cParms != 4)  /* Hardcoded value as the next lines depend on it. */
    938         || RT_FAILURE(paParms[0].getPointer ((void **) &pszPatterns, &cchPatterns))  /* patterns */
    939         || pszPatterns[cchPatterns - 1] != '\0'  /* The patterns string must be zero-terminated */
    940 /** @todo r=bird: What if cchPatterns is 0? pszPatterns is NULL then, and if it wasn't, you'd access memory
    941  * before what it points to. Add a getString() method? Please, check *all* similar cases.
    942  * Remember that the guest is not trusted. :-) */
    943         || RT_FAILURE(paParms[1].getUInt64 (&u64Timestamp))  /* timestamp */
    944         || RT_FAILURE(paParms[2].getPointer ((void **) &pchBuf, &cchBuf))  /* return buffer */
    945         || cchBuf < 1
     912        || RT_FAILURE(paParms[0].getString(&pszPatterns, &cchPatterns))  /* patterns */
     913        || RT_FAILURE(paParms[1].getUInt64(&u64Timestamp))  /* timestamp */
     914        || RT_FAILURE(paParms[2].getBuffer((void **) &pchBuf, &cchBuf))  /* return buffer */
    946915       )
    947916        rc = VERR_INVALID_PARAMETER;
     
    1028997                const char *pszPatterns;
    1029998                uint32_t cchPatterns;
    1030                 it->mParms[0].getPointer((void **) &pszPatterns, &cchPatterns);
     999                it->mParms[0].getString(&pszPatterns, &cchPatterns);
    10311000                if (prop.Matches(pszPatterns))
    10321001                {
  • trunk/src/VBox/HostServices/GuestProperties/testcase/Makefile.kmk

    r18422 r21629  
    2323include $(KBUILD_PATH)/subheader.kmk
    2424
    25 ifdef VBOX_WITH_TESTCASES
    26 #
    27 # Case conversion testcase.
    28 #
    29 PROGRAMS += tstGuestPropSvc
    30 tstGuestPropSvc_TEMPLATE = VBOXR3TSTEXE
    31 # The second define here is to ensure that the testcase will run fast, without
    32 # waiting for any thread synchronisation.
    33 tstGuestPropSvc_DEFS     = VBOX_WITH_HGCM VBOX_GUEST_PROP_TEST_NOTHREAD
    34 tstGuestPropSvc_SOURCES  = tstGuestPropSvc.cpp ../service.cpp
    35 tstGuestPropSvc_LIBS     = $(LIB_RUNTIME)
     25if defined(VBOX_WITH_TESTCASES) && !defined(VBOX_ONLY_ADDITIONS) && !defined(VBOX_ONLY_SDK)
    3626
    37 # Set this in LocalConfig.kmk if you are working on the guest property service
    38 # to automatically run the testcase at build time.
    39 ifdef VBOX_RUN_GUEST_PROPERTY_TEST
    40  ifndef VBOX_ONLY_SDK
    41   TESTING  += $(PATH_tstGuestPropSvc)/tstGuestPropSvc.run
    42   OTHERS += $(PATH_tstGuestPropSvc)/tstGuestPropSvc.run
     27 # Set this in LocalConfig.kmk if you are working on the guest property
     28 # service to automatically run the testcase at build time.
     29 #    OTHERS += $(PATH_tstGuestPropSvc)/tstGuestPropSvc.run
     30 #
     31
     32 PROGRAMS += tstGuestPropSvc
     33 TESTING  += $(PATH_tstGuestPropSvc)/tstGuestPropSvc.run
     34 tstGuestPropSvc_TEMPLATE = VBOXR3TSTEXE
     35 # The second define here is to ensure that the testcase will run fast,
     36 # without waiting for any thread synchronisation.
     37 tstGuestPropSvc_DEFS     = VBOX_WITH_HGCM VBOX_GUEST_PROP_TEST_NOTHREAD
     38 tstGuestPropSvc_SOURCES  = tstGuestPropSvc.cpp ../service.cpp
     39 tstGuestPropSvc_LIBS     = $(LIB_RUNTIME)
     40
    4341$$(PATH_tstGuestPropSvc)/tstGuestPropSvc.run: $$(INSTARGET_tstGuestPropSvc)
    4442        export VBOX_LOG_DEST=nofile; $(INSTARGET_tstGuestPropSvc) quiet
    4543        $(QUIET)$(APPEND) -t "$@" "done"
    46  endif
     44
    4745endif
    48 
    49 endif # VBOX_WITH_TESTCASES
    50 
    5146
    5247include $(KBUILD_PATH)/subfooter.kmk
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