VirtualBox

Changeset 90847 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Aug 24, 2021 1:16:58 PM (3 years ago)
Author:
vboxsync
Message:

IPRT/log: Fix loop-forver issue in LF->CRLF translation. bugref:10086

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r90829 r90847  
    45874587                cb = cbBuf - offBuf - 1;
    45884588            }
    4589             else if (cb <= 0)
     4589            else if (cb <= 2) /* 2  - Make sure we can write a \r\n and not loop forever. */
    45904590            {
    45914591                rtlogFlush(pLoggerInt, true /*fNeedSpace*/);
     
    46074607                    pLoggerInt->fPendingPrefix = true;
    46084608                }
    4609                 else if (cbBuf - offBuf < (uintptr_t)(pszNewLine - pachChars + 2))
     4609                else if ((uintptr_t)(pszNewLine - pachChars) + 2U < cbBuf - offBuf)
    46104610                {
    46114611                    cb = pszNewLine - pachChars;
     
    46134613                    pchBuf[offBuf + cb++] = '\r';
    46144614                    pchBuf[offBuf + cb++] = '\n';
    4615                     pachChars--;    /* Discount the extra '\r'. */
    46164615                    cbChars++;      /* Discount the extra '\r'. */
     4616                    pachChars--;    /* Ditto. */
    46174617                    cbRet--;        /* Ditto. */
    46184618                    pLoggerInt->fPendingPrefix = true;
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