VirtualBox

Changeset 2962 in kBuild


Ignore:
Timestamp:
Sep 22, 2016 11:30:03 PM (8 years ago)
Author:
bird
Message:

kWorker: Fixed combined console buffer overflow problem when there's a lot of errors/output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kWorker/kWorker.c

    r2961 r2962  
    72077207        {
    72087208            /* Need to grow the line buffer? */
    7209             KU32 cwcNeeded = offLastIncompleteLine != 0 ? offLastIncompleteLine : cchLastIncompleteLine + pLineBuf->u.Con.cwcBuf;
     7209            KU32 cwcNeeded = offLastIncompleteLine == 0
     7210                           ? pLineBuf->u.Con.cwcBuf + cchLastIncompleteLine /* incomplete line, append to line buffer */
     7211                           : cchLastIncompleteLine; /* Only the final incomplete line (if any) goes to the line buffer. */
    72107212            if (cwcNeeded > pLineBuf->u.Con.cwcBufAlloc)
    72117213            {
     
    72557257
    72567258        /*
    7257          * If there is sufficient combined buffer to handle this request, this are rather simple.
     7259         * If there is sufficient combined buffer to handle this request, this is rather simple.
    72587260         */
    7259         if (pLineBuf->u.Con.cwcBuf + cchLastIncompleteLine <= K_ELEMENTS(pSandbox->Combined.wszBuf))
     7261        kHlpAssert(pSandbox->Combined.cwcBuf <= K_ELEMENTS(pSandbox->Combined.wszBuf));
     7262        if (pSandbox->Combined.cwcBuf + pLineBuf->u.Con.cwcBuf + offLastIncompleteLine <= K_ELEMENTS(pSandbox->Combined.wszBuf))
    72607263        {
    72617264            if (pLineBuf->u.Con.cwcBuf > 0)
     
    72807283            KU32 offNextLine = 0;
    72817284
    7282             /* If there is buffered chars, we handle the first line outside the
     7285            /* If there are buffered chars, we handle the first line outside the
    72837286               main loop.  We must try our best outputting it as a complete line. */
    72847287            if (pLineBuf->u.Con.cwcBuf > 0)
     
    72897292                kHlpAssert(offNextLine <= offLastIncompleteLine);
    72907293
    7291                 if (pLineBuf->u.Con.cwcBuf + offNextLine + pSandbox->Combined.cwcBuf <= K_ELEMENTS(pSandbox->Combined.wszBuf))
     7294                if (pSandbox->Combined.cwcBuf + pLineBuf->u.Con.cwcBuf + offNextLine <= K_ELEMENTS(pSandbox->Combined.wszBuf))
    72927295                {
    72937296                    kHlpMemCopy(&pSandbox->Combined.wszBuf[pSandbox->Combined.cwcBuf],
     
    73367339         * Buffer any remaining incomplete line chars.
    73377340         */
    7338         if (offLastIncompleteLine < cwcToWrite)
     7341        if (cchLastIncompleteLine)
    73397342        {
    73407343            kHlpMemCopy(&pLineBuf->u.Con.pwcBuf[0], &pwcBuffer[offLastIncompleteLine], cchLastIncompleteLine * sizeof(wchar_t));
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