diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-04-10 14:54:13 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-04-10 14:54:13 -0700 |
commit | 73fb6be8290a20dbccc40de328e7860f721966c6 (patch) | |
tree | d96a737f4ff36bfa40307c2d96ce3986971227dd /core/include | |
parent | b739aab3e0345afc22c325ed62e226df6b1e3965 (diff) | |
download | pdfium-73fb6be8290a20dbccc40de328e7860f721966c6.tar.xz |
Merge to XFA: Better fix for snprintf non-termination on windows.
TBR=brucedawson@chromium.org
Review URL: https://codereview.chromium.org/1073313003
Diffstat (limited to 'core/include')
-rw-r--r-- | core/include/fxcrt/fx_system.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h index a875da5f9c..d030bf70d6 100644 --- a/core/include/fxcrt/fx_system.h +++ b/core/include/fxcrt/fx_system.h @@ -34,8 +34,9 @@ #endif #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #define _CRT_SECURE_NO_WARNINGS +#include <sal.h> #include <windows.h> -#endif +#endif // _FXM_PLATFORM_WINDOWS_ #define _FX_W32_ 1 #define _FX_W64_ 2 #ifndef _FX_WORDSIZE_ @@ -137,13 +138,18 @@ typedef FX_UINT64 FX_QWORD; #define FX_MAX(a, b) (((a) > (b)) ? (a) : (b)) #define FX_MIN(a, b) (((a) < (b)) ? (a) : (b)) #define FX_PI 3.1415926535897932384626433832795f -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -#define FXSYS_snprintf _snprintf -#define FXSYS_vsnprintf _vsnprintf + +// NOTE: prevent use of the return value from snprintf() since some platforms +// have different return values (e.g. windows _vsnprintf()), and provide +// versions that always NUL-terminate. +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900 +void FXSYS_snprintf(char *str, size_t size, _Printf_format_string_ const char* fmt, ...); +void FXSYS_vsnprintf(char *str, size_t size, const char* fmt, va_list ap); #else -#define FXSYS_snprintf snprintf -#define FXSYS_vsnprintf vsnprintf +#define FXSYS_snprintf (void) snprintf +#define FXSYS_vsnprintf (void) vsnprintf #endif + #define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE #define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE #define FXSYS_strchr strchr |