summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-05-16 10:48:51 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-16 18:28:31 +0000
commitd3a3cc24a034654b0825e4822446ddfc6a22c045 (patch)
tree49041ae111c6d611664d6b22946a9e34129d0c83 /xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
parent9774984f96946eb96eed29abfcbe824cb5858bbb (diff)
downloadpdfium-d3a3cc24a034654b0825e4822446ddfc6a22c045.tar.xz
Handle when XFA parser error handlers cannot format error messages.
Limit the length of error messages to avoid string formatting failure. Simplify some CXFA_FMParse error handling code too. BUG=chromium:708428 Change-Id: I2f5fdb61349a90b3ba681dcc04a26ce0d7f2bdda Reviewed-on: https://pdfium-review.googlesource.com/5331 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/xfa_fm2jscontext.cpp')
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index d0a111fa0d..7deab862f1 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -6144,7 +6144,7 @@ void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) {
void CXFA_FM2JSContext::ThrowNoDefaultPropertyException(
const CFX_ByteStringC& name) const {
- ThrowException(L"%s doesn't have a default property.", name.c_str());
+ ThrowException(L"%.16s doesn't have a default property.", name.c_str());
}
void CXFA_FM2JSContext::ThrowCompilerErrorException() const {
@@ -6163,14 +6163,14 @@ void CXFA_FM2JSContext::ThrowPropertyNotInObjectException(
const CFX_WideString& name,
const CFX_WideString& exp) const {
ThrowException(
- L"An attempt was made to reference property '%s' of a non-object "
- L"in SOM expression %s.",
+ L"An attempt was made to reference property '%.16s' of a non-object "
+ L"in SOM expression %.16s.",
name.c_str(), exp.c_str());
}
void CXFA_FM2JSContext::ThrowParamCountMismatchException(
const CFX_WideString& method) const {
- ThrowException(L"Incorrect number of parameters calling method '%s'.",
+ ThrowException(L"Incorrect number of parameters calling method '%.16s'.",
method.c_str());
}
@@ -6184,5 +6184,6 @@ void CXFA_FM2JSContext::ThrowException(const wchar_t* str, ...) const {
va_start(arg_ptr, str);
wsMessage.FormatV(str, arg_ptr);
va_end(arg_ptr);
+ ASSERT(!wsMessage.IsEmpty());
FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringC());
}