diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-03-10 15:23:02 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-03-10 15:23:02 -0700 |
commit | 3c676ecee839e6b0a1e5c5d4b3524edcb0bd2a42 (patch) | |
tree | 5bd53ba91d6986c216880153cda60495ac4eec12 /core/src | |
parent | 1e580a10fad09833552deb797128e00c50d74bce (diff) | |
download | pdfium-3c676ecee839e6b0a1e5c5d4b3524edcb0bd2a42.tar.xz |
Kill remaining sprintfs
I thought I had done this already, apart from the third-party
libraries, but there were a couple remaining (the third-party
libraries will still call this, they should be tweaked
upstream as needed).
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/999543002
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/fxcodec/libjpeg/fpdfapi_jerror.c | 4 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_bstring.cpp | 10 |
2 files changed, 8 insertions, 6 deletions
diff --git a/core/src/fxcodec/libjpeg/fpdfapi_jerror.c b/core/src/fxcodec/libjpeg/fpdfapi_jerror.c index 943ced798f..282f889ebd 100644 --- a/core/src/fxcodec/libjpeg/fpdfapi_jerror.c +++ b/core/src/fxcodec/libjpeg/fpdfapi_jerror.c @@ -177,9 +177,9 @@ format_message (j_common_ptr cinfo, char * buffer) /* Format the message into the passed buffer */ if (isstring) - FXSYS_sprintf(buffer, msgtext, err->msg_parm.s); + sprintf(buffer, msgtext, err->msg_parm.s); else - FXSYS_sprintf(buffer, msgtext, + sprintf(buffer, msgtext, err->msg_parm.i[0], err->msg_parm.i[1], err->msg_parm.i[2], err->msg_parm.i[3], err->msg_parm.i[4], err->msg_parm.i[5], diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp index 5c8a2fa8f3..895c8e560e 100644 --- a/core/src/fxcrt/fx_basic_bstring.cpp +++ b/core/src/fxcrt/fx_basic_bstring.cpp @@ -676,10 +676,10 @@ void CFX_ByteString::FormatV(FX_LPCSTR lpszFormat, va_list argList) if (nWidth + nPrecision > 100) { nItemLen = nPrecision + nWidth + 128; } else { - double f; char pszTemp[256]; - f = va_arg(argList, double); - FXSYS_sprintf(pszTemp, "%*.*f", nWidth, nPrecision + 6, f ); + double f = va_arg(argList, double); + memset(pszTemp, 0, sizeof(pszTemp)); + FXSYS_snprintf(pszTemp, sizeof(pszTemp) - 1, "%*.*f", nWidth, nPrecision + 6, f); nItemLen = (FX_STRSIZE)FXSYS_strlen(pszTemp); } break; @@ -697,9 +697,11 @@ void CFX_ByteString::FormatV(FX_LPCSTR lpszFormat, va_list argList) } nMaxLen += nItemLen; } + nMaxLen += 32; // Fudge factor. GetBuffer(nMaxLen); if (m_pData) { - FXSYS_vsprintf(m_pData->m_String, lpszFormat, argListSave); + memset(m_pData->m_String, 0, nMaxLen); + FXSYS_vsnprintf(m_pData->m_String, nMaxLen - 1, lpszFormat, argListSave); ReleaseBuffer(); } va_end(argListSave); |