VirtualBox

Changeset 70599 in vbox


Ignore:
Timestamp:
Jan 16, 2018 3:36:41 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120309
Message:

Main: Minor HGCM fixes, ?bugref:9064

Location:
trunk/src/VBox/Main/src-client
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/HGCM.cpp

    r69500 r70599  
    105105        VBOXHGCMSVCFNTABLE m_fntable;
    106106
    107         int m_cClients;
    108         int m_cClientsAllocated;
     107        uint32_t m_cClients;
     108        uint32_t m_cClientsAllocated;
    109109
    110110        uint32_t *m_paClientIds;
     
    12011201         * The global state of a service is configured during VM startup.
    12021202         */
    1203         int i;
     1203        uint32_t i;
    12041204
    12051205        for (i = 0; i < pSvc->m_cClients; i++)
     
    13761376                if (m_cClients == m_cClientsAllocated)
    13771377                {
    1378                     m_paClientIds = (uint32_t *)RTMemRealloc(m_paClientIds, (m_cClientsAllocated + 64) *
    1379                                                              sizeof(m_paClientIds[0]));
    1380                     Assert(m_paClientIds);
    1381                     m_cClientsAllocated += 64;
     1378                    const uint32_t cDelta = 64;
     1379
     1380                    /* Guards against integer overflow on 32bit arch and also limits size of m_paClientIds array to 4GB*/
     1381                    if (m_cClientsAllocated < UINT32_MAX / sizeof(m_paClientIds[0]) - cDelta)
     1382                    {
     1383                        uint32_t *paClientIdsNew;
     1384
     1385                        paClientIdsNew = (uint32_t *)RTMemRealloc(m_paClientIds, (m_cClientsAllocated + cDelta) *
     1386                            sizeof(m_paClientIds[0]));
     1387                        Assert(paClientIdsNew);
     1388
     1389                        if (paClientIdsNew)
     1390                        {
     1391                            m_paClientIds = paClientIdsNew;
     1392                            m_cClientsAllocated += cDelta;
     1393                        }
     1394                        else
     1395                        {
     1396                            rc = VERR_NO_MEMORY;
     1397                        }
     1398                    }
     1399                    else
     1400                    {
     1401                        rc = VERR_NO_MEMORY;
     1402                    }
    13821403                }
    13831404
     
    14431464
    14441465    /* Remove the client id from the array in any case, rc does not matter. */
    1445     int i;
     1466    uint32_t i;
    14461467
    14471468    for (i = 0; i < m_cClients; i++)
  • trunk/src/VBox/Main/src-client/VMMDevInterface.cpp

    r69500 r70599  
    617617    }
    618618
     619    /* Check if service name is a string terminated by zero*/
     620    size_t cchInfo = 0;
     621    if (RTStrNLenEx(pServiceLocation->u.host.achName, sizeof(pServiceLocation->u.host.achName), &cchInfo) != VINF_SUCCESS)
     622    {
     623        return VERR_INVALID_PARAMETER;
     624    }
     625
    619626    if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
    620627        return VERR_INVALID_STATE;
    621 
    622628    return HGCMGuestConnect(pDrv->pHGCMPort, pCmd, pServiceLocation->u.host.achName, pu32ClientID);
    623629}
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