VirtualBox

Changeset 95324 in vbox for trunk/src


Ignore:
Timestamp:
Jun 21, 2022 2:09:10 PM (3 years ago)
Author:
vboxsync
Message:

GuestProperties: No need to validate flag encoding twice in Service::setProperty, as HGCMSvcGetCStr always does it. Also, use 'cb' rather than 'cch' when the string terminator is included in the count.

File:
1 edited

Legend:

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

    r94184 r95324  
    659659int Service::setProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool isGuest)
    660660{
    661     int rc = VINF_SUCCESS;
    662661    const char *pcszName = NULL;        /* shut up gcc */
    663662    const char *pcszValue = NULL;       /* ditto */
    664663    const char *pcszFlags = NULL;
    665     uint32_t cchName = 0;               /* ditto */
    666     uint32_t cchValue = 0;              /* ditto */
    667     uint32_t cchFlags = 0;
     664    uint32_t cbName = 0;                /* ditto */
     665    uint32_t cbValue = 0;               /* ditto */
     666    uint32_t cbFlags = 0;
    668667    uint32_t fFlags = GUEST_PROP_F_NILFLAG;
    669668    uint64_t u64TimeNano = getCurrentTimestamp();
     
    674673     * General parameter correctness checking.
    675674     */
    676     if (   RT_SUCCESS(rc)
    677         && (   (cParms < 2) || (cParms > 3)  /* Hardcoded value as the next lines depend on it. */
    678             || RT_FAILURE(HGCMSvcGetCStr(&paParms[0], &pcszName, &cchName))  /* name */
    679             || RT_FAILURE(HGCMSvcGetCStr(&paParms[1], &pcszValue, &cchValue))  /* value */
    680             || (   (3 == cParms)
    681                 && RT_FAILURE(HGCMSvcGetCStr(&paParms[2], &pcszFlags, &cchFlags)) /* flags */
    682                )
     675    int rc = VINF_SUCCESS;
     676    if (   cParms < 2  /* Hardcoded value as the next lines depend on it these range checks. */
     677        || cParms > 3
     678        || RT_FAILURE(HGCMSvcGetCStr(&paParms[0], &pcszName, &cbName))  /* name */
     679        || RT_FAILURE(HGCMSvcGetCStr(&paParms[1], &pcszValue, &cbValue))  /* value */
     680        || (   cParms == 3
     681            && RT_FAILURE(HGCMSvcGetCStr(&paParms[2], &pcszFlags, &cbFlags)) /* flags */
    683682           )
    684683       )
     
    689688     */
    690689    if (RT_SUCCESS(rc))
    691         rc = GuestPropValidateName(pcszName, cchName);
     690        rc = GuestPropValidateName(pcszName, cbName);
    692691    if (RT_SUCCESS(rc))
    693         rc = GuestPropValidateValue(pcszValue, cchValue);
    694     if ((3 == cParms) && RT_SUCCESS(rc))
    695         rc = RTStrValidateEncodingEx(pcszFlags, cchFlags,
    696                                      RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
    697     if ((3 == cParms) && RT_SUCCESS(rc))
     692        rc = GuestPropValidateValue(pcszValue, cbValue);
     693    if (cParms == 3 && RT_SUCCESS(rc))
    698694        rc = GuestPropValidateFlags(pcszFlags, &fFlags);
    699695    if (RT_FAILURE(rc))
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