VirtualBox

Changeset 10017 in vbox


Ignore:
Timestamp:
Jun 30, 2008 2:06:54 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
32491
Message:

HostServices/SharedInfoService and Additions/common: deal with overflow and missing keys better when querying guest properties

Location:
trunk/src/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibInfoSvc.cpp

    r10006 r10017  
    154154        rc = Msg.hdr.result;
    155155    uint32_t cbActual;
    156     if (RT_SUCCESS(rc))
    157         rc = VbglHGCMParmUInt32Get(&Msg.size, &cbActual);
    158     if (RT_SUCCESS(rc))
     156    if (RT_SUCCESS(rc) || (VERR_BUFFER_OVERFLOW == rc))
    159157    {
    160         if (pcbActual != NULL)
    161             *pcbActual = cbActual;
    162         if (cbActual > cbValue)
    163             rc = VINF_BUFFER_OVERFLOW;
     158        int rc2 = VbglHGCMParmUInt32Get(&Msg.size, &cbActual);
     159        if (RT_SUCCESS(rc2))
     160        {
     161            if (pcbActual != NULL)
     162                *pcbActual = cbActual;
     163        }
    164164        else
    165             rc = Msg.hdr.result;
    166         if ((cbValue > 0) && (0 == cbActual))  /* No such property */
    167             pszValue[0] = 0;
     165            rc = rc2;
    168166    }
    169167    return rc;
  • trunk/src/VBox/HostServices/SharedInfoServices/service.cpp

    r10004 r10017  
    238238/**
    239239 * Retrieve a value from the guest registry by key, checking the validity
    240  * of the arguments passed.
     240 * of the arguments passed.  If the guest has not allocated enough buffer
     241 * space for the value then we return VERR_OVERFLOW and set the size of the
     242 * buffer needed in the "size" HGCM parameter.  If the key was not found at
     243 * all, we return VERR_NOT_FOUND.
    241244 *
    242245 * @returns iprt status value
     
    269272        VBoxHGCMParmUInt32Set(&paParms[2], cbValueActual);
    270273    if (RT_SUCCESS(rc) && (cbValueActual > cbValue))
    271         rc = VINF_BUFFER_OVERFLOW;
     274        rc = VERR_BUFFER_OVERFLOW;
    272275    if (RT_SUCCESS(rc) && (rc != VINF_BUFFER_OVERFLOW))
    273276        rc = CFGMR3QueryString(mpNode, pszKey, pszValue, cbValue);
     
    275278        Log2(("Queried string %s, rc=%Rrc, value=%.*s\n", pszKey, rc, cbValue, pszValue));
    276279    else if (VERR_CFGM_VALUE_NOT_FOUND == rc)
    277     {
    278         VBoxHGCMParmUInt32Set(&paParms[2], 0);
    279         rc = VINF_SUCCESS;
    280     }
     280        rc = VERR_NOT_FOUND;
    281281    LogFlowThisFunc(("rc = %Rrc\n", rc));
    282282    return rc;
     
    396396        case SET_CONFIG_KEY:
    397397            LogFlowFunc(("SET_CONFIG_KEY\n"));
    398             if (RT_SUCCESS(rc))
    399                 rc = setKey(cParms, paParms);
     398            rc = setKey(cParms, paParms);
    400399            break;
    401400
     
    403402        case DEL_CONFIG_KEY:
    404403            LogFlowFunc(("DEL_CONFIG_KEY\n"));
    405             if (RT_SUCCESS(rc))
    406                 rc = delKey(cParms, paParms);
     404            rc = delKey(cParms, paParms);
    407405            break;
    408406
     
    466464        case SET_CONFIG_KEY_HOST:
    467465            LogFlowFunc(("SET_CONFIG_KEY_HOST\n"));
    468             if (RT_SUCCESS(rc))
    469                 rc = setKey(cParms, paParms);
     466            rc = setKey(cParms, paParms);
    470467            break;
    471468
     
    473470        case DEL_CONFIG_KEY_HOST:
    474471            LogFlowFunc(("DEL_CONFIG_KEY_HOST\n"));
    475             if (RT_SUCCESS(rc))
    476                 rc = delKey(cParms, paParms);
     472            rc = delKey(cParms, paParms);
    477473            break;
    478474
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