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

Side by Side Diff: core/src/fxcrt/fx_basic_util.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 | « core/include/fxcrt/fx_string.h ('k') | core/src/fxcrt/fx_basic_wstring.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/fxcrt/fx_basic.h" 7 #include "../../include/fxcrt/fx_basic.h"
8 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 8 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <dirent.h> 10 #include <dirent.h>
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 CFX_ByteString rURI; 266 CFX_ByteString rURI;
267 int nLength = bsURI.GetLength(); 267 int nLength = bsURI.GetLength();
268 for (int i = 0; i < nLength; i++) { 268 for (int i = 0; i < nLength; i++) {
269 if (i < nLength - 2 && bsURI[i] == '%' && FX_IsXDigit(bsURI[i + 1]) && F X_IsXDigit(bsURI[i + 2])) { 269 if (i < nLength - 2 && bsURI[i] == '%' && FX_IsXDigit(bsURI[i + 1]) && F X_IsXDigit(bsURI[i + 2])) {
270 rURI += (FX_HexToI(bsURI[i + 1]) << 4 | FX_HexToI(bsURI[i + 2])); 270 rURI += (FX_HexToI(bsURI[i + 1]) << 4 | FX_HexToI(bsURI[i + 2]));
271 i += 2; 271 i += 2;
272 } else { 272 } else {
273 rURI += bsURI[i]; 273 rURI += bsURI[i];
274 } 274 }
275 } 275 }
276 return CFX_WideString::FromUTF8(rURI); 276 return CFX_WideString::FromUTF8(rURI, rURI.GetLength());
277 } 277 }
278 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 278 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
279 class CFindFileData : public CFX_Object 279 class CFindFileData : public CFX_Object
280 { 280 {
281 public: 281 public:
282 virtual ~CFindFileData() {} 282 virtual ~CFindFileData() {}
283 HANDLE m_Handle; 283 HANDLE m_Handle;
284 FX_BOOL m_bEnd; 284 FX_BOOL m_bEnd;
285 }; 285 };
286 class CFindFileDataA : public CFindFileData 286 class CFindFileDataA : public CFindFileData
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 #endif 435 #endif
436 } 436 }
437 FX_WCHAR FX_GetFolderSeparator() 437 FX_WCHAR FX_GetFolderSeparator()
438 { 438 {
439 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 439 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
440 return '\\'; 440 return '\\';
441 #else 441 #else
442 return '/'; 442 return '/';
443 #endif 443 #endif
444 } 444 }
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_string.h ('k') | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698