VirtualBox

Changeset 9882 in vbox


Ignore:
Timestamp:
Jun 23, 2008 2:58:51 PM (17 years ago)
Author:
vboxsync
Message:

HostServices/SharedInfoServices: deal with empty registry values correctly (both getting and setting)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/HostServices/VBoxInfoSvc.h

    r9809 r9882  
    3737    /** Pass the address of the console object from Main to the service */
    3838    SET_CFGM_NODE = 1,
    39     /** Get the value attached to an extra data key in the machine XML file */
     39    /**
     40     * Get the value attached to an extra data key in the machine XML file.
     41     * The parameter format matches that of GET_CONFIG_KEY.
     42     */
    4043    GET_CONFIG_KEY_HOST = 2,
    41     /** Set the value attached to an extra data key in the machine XML file */
     44    /**
     45     * Set the value attached to an extra data key in the machine XML file.
     46     * The parameter format matches that of SET_CONFIG_KEY.
     47     */
    4248    SET_CONFIG_KEY_HOST = 3
    4349};
     
    8187     *  - Less than or equal to VBOX_SHARED_INFO_KEY_MAX_LEN bytes in length
    8288     *  - Zero terminated
    83      *  - Starting with the string VBOX_SHARED_INFO_KEY_PREFIX
    8489     */
    8590    HGCMFunctionParameter key;
     
    9297    /**
    9398     * The size of the value.  If this is greater than the size of the array
    94      * supplied by the guest then no data was transferred and the call must
    95      * be repeated. (OUT uint32_t)
     99     * supplied in the second parameter then no data was transferred and the
     100     * call must be repeated.  If it is zero then no value was found.
     101     * (OUT uint32_t)
    96102     */
    97103    HGCMFunctionParameter size;
     
    108114     *  - Less than or equal to VBOX_SHARED_INFO_KEY_MAX_LEN bytes in length
    109115     *  - Zero terminated
    110      *  - Starting with the string VBOX_SHARED_INFO_KEY_PREFIX
    111116     */
    112117    HGCMFunctionParameter key;
     
    115120     * The value of the key (IN pointer)
    116121     * Criteria as for the key parameter, but with length less that or equal to
    117      * VBOX_SHARED_INFO_KEY_MAX_VALUE_LEN
     122     * VBOX_SHARED_INFO_KEY_MAX_VALUE_LEN.  A null pointer causes the value to
     123     * be removed from the database.
    118124     */
    119125    HGCMFunctionParameter value;
  • trunk/src/VBox/HostServices/SharedInfoServices/service.cpp

    r9810 r9882  
    202202    if (RT_SUCCESS(rc) && (rc != VINF_BUFFER_OVERFLOW))
    203203        Log2(("Queried string %s, rc=%Rrc, value=%.*s\n", pszKey, rc, cbValue, pcValue));
     204    else if (VERR_CFGM_VALUE_NOT_FOUND == rc)
     205    {
     206        VBoxHGCMParmUInt32Set(&paParms[2], 0);
     207        rc = VINF_SUCCESS;
     208    }
    204209    LogFlowThisFunc(("rc = %Rrc\n", rc));
    205210    return rc;
     
    285290    {
    286291        CFGMR3RemoveValue(mpNode, pszKey);
    287         rc = CFGMR3InsertString(mpNode, pszKey, pszValue);
     292        if (pszValue > 0)
     293            rc = CFGMR3InsertString(mpNode, pszKey, pszValue);
    288294    }
    289295    if (RT_SUCCESS(rc))
     
    327333        rc = VERR_INVALID_PARAMETER;
    328334
    329     /* Validate the format of the value. */
    330     /* Only accept values in printable ASCII without spaces */
    331     for (count = 0; (count < cbValue) && (pcValue[count] != '\0'); ++count)
    332         if ((pcValue[count] < 33) || (pcValue[count] > 126))
     335    if (cbValue != 0)
     336    {
     337        /* Validate the format of the value. */
     338        /* Only accept values in printable ASCII without spaces */
     339        for (count = 0; (count < cbValue) && (pcValue[count] != '\0'); ++count)
     340            if ((pcValue[count] < 33) || (pcValue[count] > 126))
     341                rc = VERR_INVALID_PARAMETER;
     342        if (RT_SUCCESS(rc) && (count == cbValue))
     343            /* This would mean that no null terminator was found */
    333344            rc = VERR_INVALID_PARAMETER;
    334     if (RT_SUCCESS(rc) && (count == cbValue))
    335         /* This would mean that no null terminator was found */
    336         rc = VERR_INVALID_PARAMETER;
    337     if (RT_SUCCESS(rc) && (count > KEY_MAX_VALUE_LEN))
    338         rc = VERR_INVALID_PARAMETER;
    339 
    340     if (RT_SUCCESS(rc))
    341         LogFlow(("    pcKey=%s, pcValue=%s\n", pcKey, pcValue));
     345        if (RT_SUCCESS(rc) && (count > KEY_MAX_VALUE_LEN))
     346            rc = VERR_INVALID_PARAMETER;
     347    }
     348
     349    if (RT_SUCCESS(rc))
     350        LogFlow(("    pcKey=%s, pcValue=%s\n", pcKey, cbValue > 0 ? pcValue : NULL));
    342351    LogFlowFunc(("returning %Rrc\n", rc));
    343352    return 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