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

Side by Side 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: Add void cast before _snprintf() just to say "I mean it man" 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 unified diff | 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')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef _FX_SYSTEM_H_ 7 #ifndef _FX_SYSTEM_H_
8 #define _FX_SYSTEM_H_ 8 #define _FX_SYSTEM_H_
9 #define _FX_WIN32_DESKTOP_ 1 9 #define _FX_WIN32_DESKTOP_ 1
10 #define _FX_LINUX_DESKTOP_ 4 10 #define _FX_LINUX_DESKTOP_ 4
(...skipping 16 matching lines...) Expand all
27 #elif defined(__APPLE__) 27 #elif defined(__APPLE__)
28 #define _FX_OS_ _FX_MACOSX_ 28 #define _FX_OS_ _FX_MACOSX_
29 #define _FXM_PLATFORM_ _FXM_PLATFORM_APPLE_ 29 #define _FXM_PLATFORM_ _FXM_PLATFORM_APPLE_
30 #endif 30 #endif
31 #endif 31 #endif
32 #if !defined(_FX_OS_) || _FX_OS_ == 0 32 #if !defined(_FX_OS_) || _FX_OS_ == 0
33 #error Sorry, can not figure out what OS you are targeting to. Please specify _F X_OS_ macro. 33 #error Sorry, can not figure out what OS you are targeting to. Please specify _F X_OS_ macro.
34 #endif 34 #endif
35 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 35 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
36 #define _CRT_SECURE_NO_WARNINGS 36 #define _CRT_SECURE_NO_WARNINGS
37 #include <sal.h>
37 #include <windows.h> 38 #include <windows.h>
38 #endif 39 #endif // _FXM_PLATFORM_WINDOWS_
39 #define _FX_W32_ 1 40 #define _FX_W32_ 1
40 #define _FX_W64_ 2 41 #define _FX_W64_ 2
41 #ifndef _FX_WORDSIZE_ 42 #ifndef _FX_WORDSIZE_
42 #if defined(_WIN64) || defined(__arm64) || defined(__arm64__) || defined(_M_AMD6 4) || defined(_M_X64) || defined(_M_IA64) || defined(__powerpc64__) || defined(_ _x86_64__) || __WORDSIZE == 64 || defined(__LP64__) 43 #if defined(_WIN64) || defined(__arm64) || defined(__arm64__) || defined(_M_AMD6 4) || defined(_M_X64) || defined(_M_IA64) || defined(__powerpc64__) || defined(_ _x86_64__) || __WORDSIZE == 64 || defined(__LP64__)
43 #define _FX_WORDSIZE_ _FX_W64_ 44 #define _FX_WORDSIZE_ _FX_W64_
44 #else 45 #else
45 #define _FX_WORDSIZE_ _FX_W32_ 46 #define _FX_WORDSIZE_ _FX_W32_
46 #endif 47 #endif
47 #endif 48 #endif
48 #include <stddef.h> 49 #include <stddef.h>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 #ifdef _DEBUG 131 #ifdef _DEBUG
131 #define ASSERT FXSYS_assert 132 #define ASSERT FXSYS_assert
132 #else 133 #else
133 134
134 #define ASSERT(a) 135 #define ASSERT(a)
135 #endif 136 #endif
136 #endif 137 #endif
137 #define FX_MAX(a, b) (((a) > (b)) ? (a) : (b)) 138 #define FX_MAX(a, b) (((a) > (b)) ? (a) : (b))
138 #define FX_MIN(a, b) (((a) < (b)) ? (a) : (b)) 139 #define FX_MIN(a, b) (((a) < (b)) ? (a) : (b))
139 #define FX_PI 3.1415926535897932384626433832795f 140 #define FX_PI 3.1415926535897932384626433832795f
140 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 141
141 #define FXSYS_snprintf» _snprintf 142 // NOTE: prevent use of the return value from snprintf(), and provide versions
142 #define FXSYS_vsnprintf»_vsnprintf 143 // that always NUL-terminate.
brucedawson 2015/04/10 18:43:19 Say why we need to prevent use of the return value
144 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900
145 void FXSYS_snprintf(char *str, size_t size, _Printf_format_string_ const char* f mt, ...);
146 void FXSYS_vsnprintf(char *str, size_t size, _Printf_format_string_ const char* fmt, va_list ap);
143 #else 147 #else
144 #define FXSYS_snprintf» snprintf 148 #define FXSYS_snprintf» (void) snprintf
145 #define FXSYS_vsnprintf»vsnprintf 149 #define FXSYS_vsnprintf»(void) vsnprintf
146 #endif 150 #endif
151
147 #define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE 152 #define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE
148 #define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE 153 #define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE
149 #define FXSYS_strchr strchr 154 #define FXSYS_strchr strchr
150 #define FXSYS_strlen strlen 155 #define FXSYS_strlen strlen
151 #define FXSYS_strncmp strncmp 156 #define FXSYS_strncmp strncmp
152 #define FXSYS_strcmp strcmp 157 #define FXSYS_strcmp strcmp
153 #define FXSYS_strcpy strcpy 158 #define FXSYS_strcpy strcpy
154 #define FXSYS_strncpy strncpy 159 #define FXSYS_strncpy strncpy
155 #define FXSYS_strstr strstr 160 #define FXSYS_strstr strstr
156 #define FXSYS_FILE FILE 161 #define FXSYS_FILE FILE
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 320
316 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 321 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
317 322
318 #if !defined(PRIuS) 323 #if !defined(PRIuS)
319 #define PRIuS "Iu" 324 #define PRIuS "Iu"
320 #endif 325 #endif
321 326
322 #endif 327 #endif
323 328
324 #endif 329 #endif
OLDNEW
« 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