VirtualBox

Changeset 2908 in kBuild


Ignore:
Timestamp:
Sep 9, 2016 10:48:40 PM (9 years ago)
Author:
bird
Message:

use alloca, get the vsnprintf check right.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/msc_buffered_printf.c

    r2907 r2908  
    9090            if (isatty(fd))
    9191            {
    92                 char szTmp[8192];
     92                char *pszTmp = (char *)alloca(16384);
    9393                va_list va2 = va;
    94                 int cchRet = vsnprintf(szTmp, sizeof(szTmp), pszFormat, va2);
    95                 if (cchRet >= sizeof(szTmp) - 1)
    96                     return (int)maybe_con_fwrite(szTmp, cchRet, 1, stdout);
     94                int cchRet = vsnprintf(pszTmp, 16384, pszFormat, va2);
     95                if (cchRet < 16384 - 1)
     96                    return (int)maybe_con_fwrite(pszTmp, cchRet, 1, stdout);
    9797            }
    9898        }
     
    131131            if (isatty(fd))
    132132            {
    133                 char szTmp[8192];
    134                 va_start(va, pszFormat);
    135                 cchRet = vsnprintf(szTmp, sizeof(szTmp), pszFormat, va);
    136                 va_end(va);
    137                 if (cchRet >= sizeof(szTmp) - 1)
    138                     return (int)maybe_con_fwrite(szTmp, cchRet, 1, pFile);
     133                char *pszTmp = (char *)alloca(16384);
     134                if (pszTmp)
     135                {
     136                    va_start(va, pszFormat);
     137                    cchRet = vsnprintf(pszTmp, 16384, pszFormat, va);
     138                    va_end(va);
     139                    if (cchRet < 16384 - 1)
     140                        return (int)maybe_con_fwrite(pszTmp, cchRet, 1, pFile);
     141                }
    139142            }
    140143        }
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