summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/include/fxcrt/fx_system.h6
-rw-r--r--core/src/fxcodec/codec/fx_codec_png.cpp6
-rw-r--r--core/src/fxcodec/libjpeg/fpdfapi_jerror.c4
-rw-r--r--core/src/fxcrt/fx_basic_bstring.cpp10
-rw-r--r--fpdfsdk/src/fpdfview.cpp9
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp7
-rw-r--r--xfa/include/fwl/core/fwl_error.h5
-rw-r--r--xfa/src/fxgraphics/src/pre.h3
8 files changed, 32 insertions, 18 deletions
diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h
index b31a60396b..a875da5f9c 100644
--- a/core/include/fxcrt/fx_system.h
+++ b/core/include/fxcrt/fx_system.h
@@ -139,11 +139,13 @@ typedef FX_UINT64 FX_QWORD;
#define FX_PI 3.1415926535897932384626433832795f
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
#define FXSYS_snprintf _snprintf
+#define FXSYS_vsnprintf _vsnprintf
#else
#define FXSYS_snprintf snprintf
+#define FXSYS_vsnprintf vsnprintf
#endif
-#define FXSYS_sprintf sprintf
-#define FXSYS_vsprintf vsprintf
+#define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE
+#define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE
#define FXSYS_strchr strchr
#define FXSYS_strlen strlen
#define FXSYS_strncmp strncmp
diff --git a/core/src/fxcodec/codec/fx_codec_png.cpp b/core/src/fxcodec/codec/fx_codec_png.cpp
index 0ddae7a7cd..8c26381514 100644
--- a/core/src/fxcodec/codec/fx_codec_png.cpp
+++ b/core/src/fxcodec/codec/fx_codec_png.cpp
@@ -50,8 +50,10 @@ static void _png_load_bmp_attribute(png_structp png_ptr, png_infop info_ptr, CFX
png_timep t = NULL;
png_get_tIME(png_ptr, info_ptr, &t);
if (t) {
- FXSYS_memset32(pAttribute->m_strTime, 0, 20);
- FXSYS_sprintf((FX_LPSTR)pAttribute->m_strTime, "%4d:%2d:%2d %2d:%2d:%2d", t->year, t->month, t->day, t->hour, t->minute, t->second);
+ FXSYS_memset32(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime));
+ FXSYS_snprintf((FX_LPSTR)pAttribute->m_strTime, sizeof(pAttribute->m_strTime), "%4d:%2d:%2d %2d:%2d:%2d",
+ t->year, t->month, t->day, t->hour, t->minute, t->second);
+ pAttribute->m_strTime[sizeof(pAttribute->m_strTime) - 1] = 0;
bTime = 1;
}
#endif
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);
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index db191245f3..c0b39ed3b8 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -572,7 +572,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int
#ifdef DEBUG_TRACE
{
char str[128];
- sprintf(str, "Rendering DIB %d x %d", width, height);
+ memset(str, 0, sizeof(str));
+ FXSYS_snprintf(str, sizeof(str) - 1, "Rendering DIB %d x %d", width, height);
CPDF_ModuleMgr::Get()->ReportError(999, str);
}
#endif
@@ -590,7 +591,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int
if (pContext->m_hBitmap == NULL) {
#if defined(DEBUG) || defined(_DEBUG)
char str[128];
- sprintf(str, "Error CreateDIBSection: %d x %d, error code = %d", width, height, GetLastError());
+ memset(str, 0, sizeof(str));
+ FXSYS_snprintf(str, sizeof(str) - 1, "Error CreateDIBSection: %d x %d, error code = %d", width, height, GetLastError());
CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, str);
#else
CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, NULL);
@@ -626,7 +628,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int
if (hMemDC == NULL) {
#if defined(DEBUG) || defined(_DEBUG)
char str[128];
- sprintf(str, "Error CreateCompatibleDC. Error code = %d", GetLastError());
+ memset(str, 0, sizeof(str));
+ FXSYS_snprintf(str, sizeof(str) - 1, "Error CreateCompatibleDC. Error code = %d", GetLastError());
CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, str);
#else
CPDF_ModuleMgr::Get()->ReportError(FPDFERR_OUT_OF_MEMORY, NULL);
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index e57eb674cc..e80d3b8e73 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -358,13 +358,16 @@ CFX_ByteString CPDFSDK_DateTime::ToPDFDateTimeString()
{
CFX_ByteString dtStr;
char tempStr[32];
- sprintf(tempStr, "D:%04d%02d%02d%02d%02d%02d", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second);
+ memset(tempStr, 0, sizeof(tempStr));
+ FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "D:%04d%02d%02d%02d%02d%02d",
+ dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second);
dtStr = CFX_ByteString(tempStr);
if (dt.tzHour < 0)
dtStr += CFX_ByteString("-");
else
dtStr += CFX_ByteString("+");
- sprintf(tempStr, "%02d'%02d'", abs(dt.tzHour), dt.tzMinute);
+ memset(tempStr, 0, sizeof(tempStr));
+ FXSYS_snprintf(tempStr, sizeof(tempStr) - 1, "%02d'%02d'", abs(dt.tzHour), dt.tzMinute);
dtStr += CFX_ByteString(tempStr);
return dtStr;
}
diff --git a/xfa/include/fwl/core/fwl_error.h b/xfa/include/fwl/core/fwl_error.h
index 4bd2ae4407..d790bee5ac 100644
--- a/xfa/include/fwl/core/fwl_error.h
+++ b/xfa/include/fwl/core/fwl_error.h
@@ -29,8 +29,9 @@ typedef FX_INT32 FWL_ERR;
{ \
if ((arg) != FWL_ERR_Succeeded) \
{ \
- char buf[16]; \
- sprintf(buf, "Error code is %d\n", arg); \
+ char buf[36]; \
+ memset(buf, 0, sizeof(buf)); \
+ FXSYS_snprintf(buf, sizeof(buf) - 1, "Error code is %d\n", arg); \
::OutputDebugString(buf); \
} \
}
diff --git a/xfa/src/fxgraphics/src/pre.h b/xfa/src/fxgraphics/src/pre.h
index dc82b35a74..ab0df3d9ac 100644
--- a/xfa/src/fxgraphics/src/pre.h
+++ b/xfa/src/fxgraphics/src/pre.h
@@ -100,7 +100,8 @@ static const FX_HATCHDATA hatchBitmapData[FX_HATCHSTYLE_Total] = {
WORD wSecond = stop.wSecond - start.wSecond; \
WORD wMilliseconds = stop.wMilliseconds - start.wMilliseconds; \
char buf[256]; \
- sprintf(buf, "duration is %d millisecond\n", wSecond * 1000 + wMilliseconds); \
+ memset(buf, 0, sizeof(buf)); \
+ snprintf(buf, sizeof(buf) - 1, "duration is %d millisecond\n", wSecond * 1000 + wMilliseconds); \
::OutputDebugString(buf);
#elif defined (__linux) || defined (linux)
#define FX_START_TIMER