diff options
author | Nicolas Pena <npm@chromium.org> | 2017-07-27 15:52:36 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-27 21:18:34 +0000 |
commit | d4362fe972442cfd2d6aa9b32134240c0ddaa6c5 (patch) | |
tree | 5975131a491697ccbb3f78b37e27cffe3e315ce5 | |
parent | 33805cc811c722a0c5cd439cff419de252cd39c9 (diff) | |
download | pdfium-d4362fe972442cfd2d6aa9b32134240c0ddaa6c5.tar.xz |
Define SIZEOF_VOIDP and other cleanup in tiffconf
This CL uses sizeof to calculate sizes in tiffconf. It adds SIZEOF_VOIDP
to allow LibTIFF to take codepaths reducing OOMs. Finally, it gets rid
of _FX_WIN32_MOBILE_ since it's never defined.
Bug: chromium:718494
Change-Id: I9e6fb2812487ccd7d08e56fd1954c716ddccd07b
Reviewed-on: https://pdfium-review.googlesource.com/9410
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
-rw-r--r-- | core/fxcrt/cfx_datetime.cpp | 6 | ||||
-rw-r--r-- | core/fxcrt/cfx_seekablestreamproxy.cpp | 3 | ||||
-rw-r--r-- | third_party/libtiff/0000-build-config.patch | 52 | ||||
-rw-r--r-- | third_party/libtiff/0001-build-config.patch | 17 | ||||
-rw-r--r-- | third_party/libtiff/tiffconf.h | 28 |
5 files changed, 33 insertions, 73 deletions
diff --git a/core/fxcrt/cfx_datetime.cpp b/core/fxcrt/cfx_datetime.cpp index b59aabcc94..a6d4636820 100644 --- a/core/fxcrt/cfx_datetime.cpp +++ b/core/fxcrt/cfx_datetime.cpp @@ -92,8 +92,7 @@ bool FX_IsLeapYear(int32_t iYear) { void CFX_DateTime::Now() { FXUT_SYSTEMTIME utLocal; -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ - _FX_OS_ == _FX_WIN64_ +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ ::GetLocalTime((LPSYSTEMTIME)&utLocal); #elif _FX_OS_ != _FX_EMBEDDED_ timeval curTime; @@ -109,8 +108,7 @@ void CFX_DateTime::Now() { utLocal.wMinute = st.tm_min; utLocal.wSecond = st.tm_sec; utLocal.wMillisecond = curTime.tv_usec / 1000; -#endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || - // _FX_OS_ == _FX_WIN64_ +#endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ year_ = utLocal.wYear; month_ = static_cast<uint8_t>(utLocal.wMonth); diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp index 8cf855217a..9b44f95d13 100644 --- a/core/fxcrt/cfx_seekablestreamproxy.cpp +++ b/core/fxcrt/cfx_seekablestreamproxy.cpp @@ -6,8 +6,7 @@ #include "core/fxcrt/cfx_seekablestreamproxy.h" -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ - _FX_OS_ == _FX_WIN64_ +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ #include <io.h> #endif diff --git a/third_party/libtiff/0000-build-config.patch b/third_party/libtiff/0000-build-config.patch index a422b37db8..60f79b74b2 100644 --- a/third_party/libtiff/0000-build-config.patch +++ b/third_party/libtiff/0000-build-config.patch @@ -68,7 +68,7 @@ diff a/third_party/libtiff/tif_ojpeg.c b/third_party/libtiff/tif_ojpeg.c diff a/third_party/libtiff/tiffconf.h b/third_party/libtiff/tiffconf.h --- /dev/null +++ b/third_party/libtiff/tiffconf.h -@@ -0,0 +1,248 @@ +@@ -0,0 +1,239 @@ +/* libtiff/tiffconf.h. Generated by configure. */ +/* + Configuration defines for installed libtiff. @@ -81,20 +81,10 @@ diff a/third_party/libtiff/tiffconf.h b/third_party/libtiff/tiffconf.h +#include "core/fxcrt/fx_system.h" + +//NOTE: The tiff codec requires an ANSI C compiler environment for building and -+// presumes an ANSI C environment for use. -+ -+/* Define to 1 if you have the <fcntl.h> header file. */ -+/* Define to 1 if you have the <sys/types.h> header file. */ -+#if _FX_OS_ == _FX_WIN32_MOBILE_ -+# define O_RDONLY 0x0000 /* open for reading only */ -+# define O_WRONLY 0x0001 /* open for writing only */ -+# define O_RDWR 0x0002 /* open for reading and writing */ -+# define O_CREAT 0x0100 /* create and open file */ -+# define O_TRUNC 0x0200 /* open and truncate */ -+#else ++// presumes an ANSI C environment for use. ++ +# define HAVE_SYS_TYPES_H 1 +# define HAVE_FCNTL_H 1 -+#endif + +/* Compatibility stuff. */ + @@ -110,21 +100,23 @@ diff a/third_party/libtiff/tiffconf.h b/third_party/libtiff/tiffconf.h +//fx_system.h already include the string.h in ANSIC + +/* Define to 1 if you have the <search.h> header file. */ -+/*#define HAVE_SEARCH_H 1 */ ++#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ && _MSC_VER >= 1900 ++// search.h is always available in VS 2015 and above, and may be ++// available in earlier versions. ++#define HAVE_SEARCH_H 1 ++#endif + ++static const size_t sizeOfInt = sizeof(int); +/* The size of a `int', as computed by sizeof. */ -+/* According typedef int int32_t; in the fx_system.h*/ -+#define SIZEOF_INT 4 ++#define SIZEOF_INT sizeOfInt + -+/* Sunliang.Liu 20110325. We should config the correct long size for tif -+ fax4decode optimize in tif_fax3.c -- Linux64 decode issue. -+ TESTDOC: Bug #23661 - z1.tif. */ -+#if _FX_CPU_ == _FX_WIN64_ || _FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ ++static const size_t sizeOfULong = sizeof(unsigned long); +/* The size of `unsigned long', as computed by sizeof. */ -+#define SIZEOF_UNSIGNED_LONG 8 -+#else -+#define SIZEOF_UNSIGNED_LONG 4 -+#endif ++#define SIZEOF_UNSIGNED_LONG sizeOfULong ++ ++static const size_t sizeOfVoidP = sizeof(void*); ++/* The size of void* as computed by sizeof. */ ++#define SIZEOF_VOIDP sizeOfVoidP + +/* Signed 8-bit type */ +#define TIFF_INT8_T signed char @@ -150,7 +142,7 @@ diff a/third_party/libtiff/tiffconf.h b/third_party/libtiff/tiffconf.h +/* Unsigned 32-bit type formatter */ +#define TIFF_UINT32_FORMAT "%u" + -+#ifdef _MSC_VER // windows ++#ifdef _MSC_VER // windows + +/* Signed 64-bit type formatter */ +#define TIFF_INT64_FORMAT "%I64d" @@ -164,9 +156,9 @@ diff a/third_party/libtiff/tiffconf.h b/third_party/libtiff/tiffconf.h +/* Unsigned 64-bit type */ +#define TIFF_UINT64_T unsigned __int64 + -+#else // linux/unix ++#else // linux/unix + -+#if 0 //_FX_CPU_ == _FX_X64_ // linux/unix 64 ++#if 0 //_FX_CPU_ == _FX_X64_ // linux/unix 64 + +/* Signed 64-bit type formatter */ +#define TIFF_INT64_FORMAT "%ld" @@ -177,7 +169,7 @@ diff a/third_party/libtiff/tiffconf.h b/third_party/libtiff/tiffconf.h +/* Signed 64-bit type */ +#define TIFF_INT64_T signed long + -+#else // linux/unix 32 ++#else // linux/unix 32 + +/* Signed 64-bit type formatter */ +#define TIFF_INT64_FORMAT "%lld" @@ -188,7 +180,7 @@ diff a/third_party/libtiff/tiffconf.h b/third_party/libtiff/tiffconf.h +/* Signed 64-bit type */ +#define TIFF_INT64_T signed long long + -+#endif // end _FX_CPU_ ++#endif // end _FX_CPU_ + +/* Unsigned 64-bit type */ +#define TIFF_UINT64_T unsigned long long @@ -271,7 +263,7 @@ diff a/third_party/libtiff/tiffconf.h b/third_party/libtiff/tiffconf.h + +/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation + fails with unpatched IJG JPEG library) */ -+#define OJPEG_SUPPORT 1 ++#define OJPEG_SUPPORT 1 + +/* Support Macintosh PackBits algorithm */ +#define PACKBITS_SUPPORT 1 diff --git a/third_party/libtiff/0001-build-config.patch b/third_party/libtiff/0001-build-config.patch deleted file mode 100644 index c393154658..0000000000 --- a/third_party/libtiff/0001-build-config.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/third_party/libtiff/tiffconf.h b/third_party/libtiff/tiffconf.h -index bcc0bc5..ca749da 100644 ---- a/third_party/libtiff/tiffconf.h -+++ b/third_party/libtiff/tiffconf.h -@@ -39,7 +39,11 @@ - //fx_system.h already include the string.h in ANSIC - - /* Define to 1 if you have the <search.h> header file. */ --/*#define HAVE_SEARCH_H 1 */ -+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ && _MSC_VER >= 1900 -+// search.h is always available in VS 2015 and above, and may be -+// available in earlier versions. -+#define HAVE_SEARCH_H 1 -+#endif - - /* The size of a `int', as computed by sizeof. */ - /* According typedef int int32_t; in the fx_system.h*/ diff --git a/third_party/libtiff/tiffconf.h b/third_party/libtiff/tiffconf.h index 26de163aba..2a88cb75f4 100644 --- a/third_party/libtiff/tiffconf.h +++ b/third_party/libtiff/tiffconf.h @@ -12,18 +12,8 @@ //NOTE: The tiff codec requires an ANSI C compiler environment for building and // presumes an ANSI C environment for use. -/* Define to 1 if you have the <fcntl.h> header file. */ -/* Define to 1 if you have the <sys/types.h> header file. */ -#if _FX_OS_ == _FX_WIN32_MOBILE_ -# define O_RDONLY 0x0000 /* open for reading only */ -# define O_WRONLY 0x0001 /* open for writing only */ -# define O_RDWR 0x0002 /* open for reading and writing */ -# define O_CREAT 0x0100 /* create and open file */ -# define O_TRUNC 0x0200 /* open and truncate */ -#else # define HAVE_SYS_TYPES_H 1 # define HAVE_FCNTL_H 1 -#endif /* Compatibility stuff. */ @@ -45,19 +35,17 @@ #define HAVE_SEARCH_H 1 #endif +static const size_t sizeOfInt = sizeof(int); /* The size of a `int', as computed by sizeof. */ -/* According typedef int int32_t; in the fx_system.h*/ -#define SIZEOF_INT 4 +#define SIZEOF_INT sizeOfInt -/* Sunliang.Liu 20110325. We should config the correct long size for tif - fax4decode optimize in tif_fax3.c -- Linux64 decode issue. - TESTDOC: Bug #23661 - z1.tif. */ -#if _FX_CPU_ == _FX_WIN64_ || _FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ +static const size_t sizeOfULong = sizeof(unsigned long); /* The size of `unsigned long', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_LONG 8 -#else -#define SIZEOF_UNSIGNED_LONG 4 -#endif +#define SIZEOF_UNSIGNED_LONG sizeOfULong + +static const size_t sizeOfVoidP = sizeof(void*); +/* The size of void* as computed by sizeof. */ +#define SIZEOF_VOIDP sizeOfVoidP /* Signed 8-bit type */ #define TIFF_INT8_T signed char |