VirtualBox

Changeset 84843 in vbox


Ignore:
Timestamp:
Jun 16, 2020 9:44:14 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
138655
Message:

Guest Control/Main: Resolved another todo: Limit the default size a guest process stream buffer can grow to 32MB. bugref:9320.

File:
1 edited

Legend:

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

    r84745 r84843  
    523523
    524524GuestProcessStream::GuestProcessStream(void)
    525     : m_cbAllocated(0),
    526       m_cbUsed(0),
    527       m_offBuffer(0),
    528       m_pbBuffer(NULL)
    529 {
    530 
    531 }
     525    : m_cbMax(_32M)
     526    , m_cbAllocated(0)
     527    , m_cbUsed(0)
     528    , m_offBuffer(0)
     529    , m_pbBuffer(NULL) { }
    532530
    533531GuestProcessStream::~GuestProcessStream(void)
     
    540538 * are multiple rounds of adding data needed.
    541539 *
    542  * @return  VBox status code.
     540 * @return  VBox status code. Will return VERR_TOO_MUCH_DATA if the buffer's maximum (limit) has been reached.
    543541 * @param   pbData              Pointer to data to add.
    544542 * @param   cbData              Size (in bytes) of data to add.
     
    579577        if (cbData + m_cbUsed > m_cbAllocated)
    580578        {
    581 /** @todo Put an upper limit on the allocation?   */
    582579            size_t cbAlloc = m_cbUsed + cbData;
    583             cbAlloc = RT_ALIGN_Z(cbAlloc, _64K);
    584             void *pvNew = RTMemRealloc(m_pbBuffer, cbAlloc);
    585             if (pvNew)
     580            if (cbAlloc <= m_cbMax)
    586581            {
    587                 m_pbBuffer = (uint8_t *)pvNew;
    588                 m_cbAllocated = cbAlloc;
     582                cbAlloc = RT_ALIGN_Z(cbAlloc, _64K);
     583                void *pvNew = RTMemRealloc(m_pbBuffer, cbAlloc);
     584                if (pvNew)
     585                {
     586                    m_pbBuffer = (uint8_t *)pvNew;
     587                    m_cbAllocated = cbAlloc;
     588                }
     589                else
     590                    rc = VERR_NO_MEMORY;
    589591            }
    590592            else
    591                 rc = VERR_NO_MEMORY;
     593                rc = VERR_TOO_MUCH_DATA;
    592594        }
    593595
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