VirtualBox

Changeset 36872 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 28, 2011 8:53:57 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71449
Message:

HostServices/GuestCtrl: Fixed several bugs revealed by upcoming testcase.

File:
1 edited

Legend:

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

    r36743 r36872  
    309309int Service::paramBufferAllocate(PVBOXGUESTCTRPARAMBUFFER pBuf, uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
    310310{
    311     AssertPtr(pBuf);
    312     int rc = VINF_SUCCESS;
     311    AssertPtrReturn(pBuf, VERR_INVALID_POINTER);
     312    if (cParms)
     313        AssertPtrReturn(paParms, VERR_INVALID_POINTER);
    313314
    314315    /* Paranoia. */
    315316    if (cParms > 256)
    316317        cParms = 256;
     318
     319    int rc = VINF_SUCCESS;
    317320
    318321    /*
     
    321324     * in an unmodified state.
    322325     */
    323     if (RT_SUCCESS(rc))
    324     {
    325         pBuf->uMsg = uMsg;
    326         pBuf->uParmCount = cParms;
     326    pBuf->uMsg = uMsg;
     327    pBuf->uParmCount = cParms;
     328    if (pBuf->uParmCount)
     329    {
    327330        pBuf->pParms = (VBOXHGCMSVCPARM*)RTMemAlloc(sizeof(VBOXHGCMSVCPARM) * pBuf->uParmCount);
    328331        if (NULL == pBuf->pParms)
    329         {
    330332            rc = VERR_NO_MEMORY;
    331         }
    332         else
    333         {
    334             for (uint32_t i = 0; i < pBuf->uParmCount; i++)
     333    }
     334
     335    if (RT_SUCCESS(rc))
     336    {
     337        for (uint32_t i = 0; i < pBuf->uParmCount; i++)
     338        {
     339            pBuf->pParms[i].type = paParms[i].type;
     340            switch (paParms[i].type)
    335341            {
    336                 pBuf->pParms[i].type = paParms[i].type;
    337                 switch (paParms[i].type)
    338                 {
    339                     case VBOX_HGCM_SVC_PARM_32BIT:
    340                         pBuf->pParms[i].u.uint32 = paParms[i].u.uint32;
    341                         break;
    342 
    343                     case VBOX_HGCM_SVC_PARM_64BIT:
    344                         /* Not supported yet. */
    345                         break;
    346 
    347                     case VBOX_HGCM_SVC_PARM_PTR:
    348                         pBuf->pParms[i].u.pointer.size = paParms[i].u.pointer.size;
    349                         if (pBuf->pParms[i].u.pointer.size > 0)
     342                case VBOX_HGCM_SVC_PARM_32BIT:
     343                    pBuf->pParms[i].u.uint32 = paParms[i].u.uint32;
     344                    break;
     345
     346                case VBOX_HGCM_SVC_PARM_64BIT:
     347                    /* Not supported yet. */
     348                    break;
     349
     350                case VBOX_HGCM_SVC_PARM_PTR:
     351                    pBuf->pParms[i].u.pointer.size = paParms[i].u.pointer.size;
     352                    if (pBuf->pParms[i].u.pointer.size > 0)
     353                    {
     354                        pBuf->pParms[i].u.pointer.addr = RTMemAlloc(pBuf->pParms[i].u.pointer.size);
     355                        if (NULL == pBuf->pParms[i].u.pointer.addr)
    350356                        {
    351                             pBuf->pParms[i].u.pointer.addr = RTMemAlloc(pBuf->pParms[i].u.pointer.size);
    352                             if (NULL == pBuf->pParms[i].u.pointer.addr)
    353                             {
    354                                 rc = VERR_NO_MEMORY;
    355                                 break;
    356                             }
    357                             else
    358                                 memcpy(pBuf->pParms[i].u.pointer.addr,
    359                                        paParms[i].u.pointer.addr,
    360                                        pBuf->pParms[i].u.pointer.size);
     357                            rc = VERR_NO_MEMORY;
     358                            break;
    361359                        }
    362360                        else
    363                         {
    364                             /* Size is 0 -- make sure we don't have any pointer. */
    365                             pBuf->pParms[i].u.pointer.addr = NULL;
    366                         }
    367                         break;
    368 
    369                     default:
    370                         break;
    371                 }
    372                 if (RT_FAILURE(rc))
     361                            memcpy(pBuf->pParms[i].u.pointer.addr,
     362                                   paParms[i].u.pointer.addr,
     363                                   pBuf->pParms[i].u.pointer.size);
     364                    }
     365                    else
     366                    {
     367                        /* Size is 0 -- make sure we don't have any pointer. */
     368                        pBuf->pParms[i].u.pointer.addr = NULL;
     369                    }
     370                    break;
     371
     372                default:
    373373                    break;
    374374            }
     375            if (RT_FAILURE(rc))
     376                break;
    375377        }
    376378    }
     
    785787    if (mNumClients == 0)
    786788        return VERR_NOT_FOUND;
    787 
    788789    HostCmd newCmd;
    789790    int rc = paramBufferAllocate(&newCmd.mParmBuf, eFunction, cParms, paParms);
    790     if (   RT_SUCCESS(rc)
    791         && newCmd.mParmBuf.uParmCount > 0)
     791    if (RT_SUCCESS(rc) && cParms)
    792792    {
    793793        /*
     
    799799    }
    800800
    801     bool fProcessed = false;
    802801    if (RT_SUCCESS(rc))
    803802    {
     803        bool fProcessed = false;
     804
    804805        /* Can we wake up a waiting client on guest? */
    805806        if (!mClientWaiterList.empty())
     
    814815            mClientWaiterList.pop_front();
    815816
    816             /* If we got VERR_TOO_MUCH_DATA we buffer the host command in the next block
    817              * and return success to the host. */
    818             if (rc == VERR_TOO_MUCH_DATA)
     817            /*
     818             * If we got back an error (like VERR_TOO_MUCH_DATA or VERR_BUFFER_OVERFLOW)
     819             * we buffer the host command in the next block and return success to the host.
     820             */
     821            if (RT_FAILURE(rc))
    819822            {
    820823                rc = VINF_SUCCESS;
     
    932935        switch (eFunction)
    933936        {
     937            case HOST_CANCEL_PENDING_WAITS:
     938                LogFlowFunc(("HOST_CANCEL_PENDING_WAITS\n"));
     939                rc = processHostCmd(eFunction, cParms, paParms);
     940                break;
     941
    934942            /* The host wants to execute something. */
    935943            case HOST_EXEC_CMD:
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