Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2002)

Unified Diff: core/include/fxcrt/fx_system.h

Issue 1077903002: Better fix for snprintf non-termination on windows. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Implement Bruce's suggestion about void returns. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/src/fxcrt/fx_basic_util.cpp » ('j') | core/src/fxcrt/fx_basic_util.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/include/fxcrt/fx_system.h
diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h
index a875da5f9c6fb035a8c26730eb8ebd93672a1239..328fbb9fab1aced0d803b0857afae275c609e627 100644
--- a/core/include/fxcrt/fx_system.h
+++ b/core/include/fxcrt/fx_system.h
@@ -137,13 +137,17 @@ 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
+
+// NOTE: never trust the return value from snprintf(), but provide versions
+// that always NUL-terminate.
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
brucedawson 2015/04/10 18:03:02 Consider making times version limited. When VS 201
Tom Sepez 2015/04/10 18:23:40 Done.
-#define FXSYS_snprintf _snprintf
-#define FXSYS_vsnprintf _vsnprintf
+void FXSYS_snprintf(char *str, size_t size, const char* fmt, ...);
brucedawson 2015/04/10 18:03:02 Consider adding SAL annotations that let /analyze
Tom Sepez 2015/04/10 18:23:40 Done.
+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
« no previous file with comments | « no previous file | core/src/fxcrt/fx_basic_util.cpp » ('j') | core/src/fxcrt/fx_basic_util.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698