summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-02-01 14:52:34 +0100
committerTor Andersson <tor.andersson@artifex.com>2016-02-09 16:54:20 +0100
commit482d9590b54308e7b2f83cdf4180426c38444894 (patch)
treec95d00404a2bc51ab646250161a8cddb19d94552
parentd96bd69b94c12906473a4721c2c2dc5941923253 (diff)
downloadmupdf-482d9590b54308e7b2f83cdf4180426c38444894.tar.xz
Don't use unsafe _snprintf on MSVC older than 2015.
Wrap the unsafe _snprintf to ensure that the string is null-terminated even on overflow.
-rw-r--r--include/mupdf/fitz/system.h25
m---------thirdparty/mujs0
2 files changed, 23 insertions, 2 deletions
diff --git a/include/mupdf/fitz/system.h b/include/mupdf/fitz/system.h
index aeb5686c..abc3b9b7 100644
--- a/include/mupdf/fitz/system.h
+++ b/include/mupdf/fitz/system.h
@@ -112,11 +112,32 @@ struct timeval;
struct timezone;
int gettimeofday(struct timeval *tv, struct timezone *tz);
-#define snprintf _snprintf
-#if _MSC_VER < 1800
+#if _MSC_VER < 1900 /* MSVC 2015 */
+#define snprintf msvc_snprintf
+#define vsnprintf msvc_vsnprintf
+static int msvc_vsnprintf(char *str, size_t size, const char *fmt, va_list ap)
+{
+ int n;
+ n = _vsnprintf(str, size, fmt, ap);
+ str[size-1] = 0;
+ return n;
+}
+static int msvc_snprintf(char *str, size_t size, const char *fmt, ...)
+{
+ int n;
+ va_list ap;
+ va_start(ap, fmt);
+ n = msvc_vsnprintf(str, size, fmt, ap);
+ va_end(ap);
+ return n;
+}
+#endif
+
+#if _MSC_VER < 1700 /* MSVC 2012 */
#define isnan(x) _isnan(x)
#define isinf(x) (!_finite(x))
#endif
+
#define hypotf _hypotf
FILE *fz_fopen_utf8(const char *name, const char *mode);
diff --git a/thirdparty/mujs b/thirdparty/mujs
-Subproject d800b59f0f0fabc15f3eb572ab85baefc0a7ede
+Subproject a462ed445fba17987b9138c0c9b14d4e640910e