VirtualBox

Changeset 106675 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Oct 24, 2024 9:37:40 PM (4 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165539
Message:

Devices/Network: Fix stack overflow on pipe read. bugref:10268

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvNATlibslirp.cpp

    r106619 r106675  
    775775             * so to avoid false alarm drain pipe here to the very end
    776776             */
    777             char ch;
     777            char ch[1024];
    778778            size_t cbRead;
    779779            uint64_t cbWakeupNotifs = ASMAtomicReadU64(&pThis->cbWakeupNotifs);
    780             RTPipeRead(pThis->hPipeRead, &ch, cbWakeupNotifs, &cbRead);
    781             ASMAtomicSubU64(&pThis->cbWakeupNotifs, cbRead);
     780
     781            if (cbWakeupNotifs > 1024)
     782            {
     783                RTPipeRead(pThis->hPipeRead, &ch, 1024, &cbRead);
     784                ASMAtomicSubU64(&pThis->cbWakeupNotifs, 1024);
     785            }
     786            else
     787            {
     788                RTPipeRead(pThis->hPipeRead, &ch, cbWakeupNotifs, &cbRead);
     789                ASMAtomicSubU64(&pThis->cbWakeupNotifs, cbRead);
     790            }
    782791        }
    783792
     
    791800        slirp_pollfds_fill(pThis->pNATState->pSlirp, &msTimeout, drvNAT_AddPollCb /* SlirpAddPollCb */, pThis /* opaque */);
    792801        drvNAT_UpdateTimeout(&msTimeout, pThis);
    793 
     802.h
    794803        int cChangedFDs = WSAPoll(pThis->pNATState->polls, pThis->pNATState->nsock, msTimeout /* timeout */);
    795804        int error = WSAGetLastError();
     
    808817             * so to avoid false alarm drain pipe here to the very end
    809818             */
    810             char ch;
     819            char ch[1024];
    811820            size_t cbRead;
    812821            uint64_t cbWakeupNotifs = ASMAtomicReadU64(&pThis->cbWakeupNotifs);
    813             cbRead = recv(pThis->pWakeupSockPair[1], &ch, cbWakeupNotifs, NULL);
    814             ASMAtomicSubU64(&pThis->cbWakeupNotifs, cbRead);
     822
     823            if (cbWakeupNotifs > 1024)
     824            {
     825                cbRead = recv(pThis->pWakeupSockPair[1], &ch, 1024, NULL);
     826                ASMAtomicSubU64(&pThis->cbWakeupNotifs, 1024);
     827            }
     828            else
     829            {
     830                cbRead = recv(pThis->pWakeupSockPair[1], &ch, cbWakeupNotifs, NULL);
     831                ASMAtomicSubU64(&pThis->cbWakeupNotifs, cbRead);
     832            }
    815833        }
    816834
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