summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_system.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-24 15:55:11 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-24 23:23:34 +0000
commit9ff306d958e178843b292044ce208cda86adc825 (patch)
treec3043b4242fe89ce299ca4a653fd23ebbf965518 /core/fxcrt/fx_system.cpp
parent64ee2c3fe2a21d0471595ae486d7e55e2eadfb57 (diff)
downloadpdfium-9ff306d958e178843b292044ce208cda86adc825.tar.xz
Add FXSYS_wcsftime() to avoid termination on win.
Bug: 712725 Change-Id: I3384385176410964a87b12c2587f68247ea80cc9 Reviewed-on: https://pdfium-review.googlesource.com/4454 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt/fx_system.cpp')
-rw-r--r--core/fxcrt/fx_system.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/fxcrt/fx_system.cpp b/core/fxcrt/fx_system.cpp
new file mode 100644
index 0000000000..d2b04f502a
--- /dev/null
+++ b/core/fxcrt/fx_system.cpp
@@ -0,0 +1,28 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fxcrt/fx_system.h"
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+
+size_t FXSYS_wcsftime(wchar_t* strDest,
+ size_t maxsize,
+ const wchar_t* format,
+ const struct tm* timeptr) {
+ // Avoid tripping an invalid parameter handler and crashing process.
+ // Note: leap seconds may cause tm_sec == 60.
+ if (timeptr->tm_year < 0 || timeptr->tm_mon < 0 || timeptr->tm_mon > 11 ||
+ timeptr->tm_mday < 1 || timeptr->tm_mday > 31 || timeptr->tm_hour < 0 ||
+ timeptr->tm_hour > 23 || timeptr->tm_min < 0 || timeptr->tm_min > 59 ||
+ timeptr->tm_sec < 0 || timeptr->tm_sec > 60 || timeptr->tm_wday < 0 ||
+ timeptr->tm_wday > 6 || timeptr->tm_yday < 0 || timeptr->tm_yday > 365) {
+ strDest[0] = L'\0';
+ return 0;
+ }
+ return wcsftime(strDest, maxsize, format, timeptr);
+}
+
+#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_