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

Side by Side Diff: fpdfsdk/src/javascript/app.cpp

Issue 383563002: Fix an out-of-boundary issue for wide string (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Add WStringLength function Created 6 years, 5 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 | « fpdfsdk/src/javascript/Document.cpp ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »
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 #include "../../include/javascript/JavaScript.h" 7 #include "../../include/javascript/JavaScript.h"
8 #include "../../include/javascript/IJavaScript.h" 8 #include "../../include/javascript/IJavaScript.h"
9 #include "../../include/javascript/JS_Define.h" 9 #include "../../include/javascript/JS_Define.h"
10 #include "../../include/javascript/JS_Object.h" 10 #include "../../include/javascript/JS_Object.h"
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 v8::Isolate* isolate = GetIsolate(cc); 879 v8::Isolate* isolate = GetIsolate(cc);
880 880
881 bool bSave = false; 881 bool bSave = false;
882 CFX_ByteString cFilenameInit = CFX_ByteString(); 882 CFX_ByteString cFilenameInit = CFX_ByteString();
883 CFX_ByteString cFSInit = CFX_ByteString(); 883 CFX_ByteString cFSInit = CFX_ByteString();
884 884
885 if(params.size()>0 && (params[0].GetType() == VT_object)) 885 if(params.size()>0 && (params[0].GetType() == VT_object))
886 { 886 {
887 JSObject pObj = (JSObject )params[0]; 887 JSObject pObj = (JSObject )params[0];
888 888
889 » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"bSave"); 889 » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"bSave");
890 » » » bSave = (bool)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pV alue)); 890 » » » bSave = (bool)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pV alue));
891 » » 891 » »
892 pValue = JS_GetObjectElement(isolate, pObj,L"cFilenameInit"); 892 pValue = JS_GetObjectElement(isolate, pObj,L"cFilenameInit");
893 { 893 {
894 CJS_Value t = CJS_Value(isolate, pValue, GET_VALUE_TYPE( pValue)); 894 CJS_Value t = CJS_Value(isolate, pValue, GET_VALUE_TYPE( pValue));
895 » » » cFilenameInit = t.operator CFX_ByteString(); 895 » » » cFilenameInit = t.operator CFX_ByteString();
896 } 896 }
897 » » 897 » »
898 pValue = JS_GetObjectElement(isolate,pObj,L"cFSInit"); 898 pValue = JS_GetObjectElement(isolate,pObj,L"cFSInit");
899 { 899 {
900 CJS_Value t = CJS_Value(isolate, pValue, GET_VALUE_TYPE( pValue)); 900 CJS_Value t = CJS_Value(isolate, pValue, GET_VALUE_TYPE( pValue));
901 cFSInit = t.operator CFX_ByteString(); 901 cFSInit = t.operator CFX_ByteString();
902 } 902 }
903 } 903 }
904 else 904 else
905 { 905 {
906 if(params.size() >= 1) 906 if(params.size() >= 1)
907 { 907 {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 swDefault = params[2]; 1090 swDefault = params[2];
1091 bPassWord = params[3]; 1091 bPassWord = params[3];
1092 swLabel = params[4]; 1092 swLabel = params[4];
1093 break; 1093 break;
1094 default: 1094 default:
1095 break; 1095 break;
1096 } 1096 }
1097 } 1097 }
1098 1098
1099 CJS_Context* pContext = (CJS_Context *)cc; 1099 CJS_Context* pContext = (CJS_Context *)cc;
1100 » ASSERT(pContext != NULL); 1100 » ASSERT(pContext != NULL);
1101 1101
1102 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); 1102 CPDFDoc_Environment* pApp = pContext->GetReaderApp();
1103 » ASSERT(pApp != NULL); 1103 » ASSERT(pApp != NULL);
1104 int nLength = 2048; 1104 int nLength = 2048;
1105 char* pBuff = new char[nLength]; 1105 char* pBuff = new char[nLength];
1106 nLength = pApp->JS_appResponse(swQuestion, swTitle, swDefault, swLabel, bPassWord, pBuff, nLength); 1106 nLength = pApp->JS_appResponse(swQuestion, swTitle, swDefault, swLabel, bPassWord, pBuff, nLength);
1107 if(nLength<=0) 1107 if(nLength<=0)
1108 { 1108 {
1109 delete[] pBuff;
1109 vRet.SetNull(); 1110 vRet.SetNull();
1110 return FALSE; 1111 return FALSE;
1111 } 1112 }
1112 else 1113 else
1113 { 1114 {
1114 » » nLength = nLength>2046?2046:nLength; 1115 » » nLength = nLength > sizeof(pBuff) ? sizeof(pBuff) : nLength;
1115 pBuff[nLength] = 0; 1116 vRet = swResponse = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLength / 2);
1116 pBuff[nLength+1] = 0;
1117 » » swResponse = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLength);
1118 » » vRet = swResponse;
1119 } 1117 }
1120 delete[] pBuff; 1118 delete[] pBuff;
1121 1119
1122 return TRUE; 1120 return TRUE;
1123 } 1121 }
1124 1122
1125 FX_BOOL app::media(OBJ_PROP_PARAMS) 1123 FX_BOOL app::media(OBJ_PROP_PARAMS)
1126 { 1124 {
1127 return FALSE; 1125 return FALSE;
1128 } 1126 }
1129 1127
1130 FX_BOOL app::execDialog(OBJ_METHOD_PARAMS) 1128 FX_BOOL app::execDialog(OBJ_METHOD_PARAMS)
1131 { 1129 {
1132 return TRUE; 1130 return TRUE;
1133 } 1131 }
1134 1132
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/Document.cpp ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698