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

Side by Side Diff: fpdfsdk/src/fsdk_baseform.cpp

Issue 1710403002: Use safe arithmentic in CFX_BinaryBuf::ExpandBuf. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: needless uint8_t casts. Created 4 years, 10 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/src/fxcrt/fx_basic_buffer.cpp ('k') | xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.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 "fpdfsdk/include/fsdk_baseform.h" 7 #include "fpdfsdk/include/fsdk_baseform.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 2443 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictBy("FDF"); 2454 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictBy("FDF");
2455 if (!pMainDict) 2455 if (!pMainDict)
2456 return FALSE; 2456 return FALSE;
2457 2457
2458 // Get fields 2458 // Get fields
2459 CPDF_Array* pFields = pMainDict->GetArrayBy("Fields"); 2459 CPDF_Array* pFields = pMainDict->GetArrayBy("Fields");
2460 if (!pFields) 2460 if (!pFields)
2461 return FALSE; 2461 return FALSE;
2462 2462
2463 CFX_ByteTextBuf fdfEncodedData; 2463 CFX_ByteTextBuf fdfEncodedData;
2464
2465 for (FX_DWORD i = 0; i < pFields->GetCount(); i++) { 2464 for (FX_DWORD i = 0; i < pFields->GetCount(); i++) {
2466 CPDF_Dictionary* pField = pFields->GetDictAt(i); 2465 CPDF_Dictionary* pField = pFields->GetDictAt(i);
2467 if (!pField) 2466 if (!pField)
2468 continue; 2467 continue;
2469 CFX_WideString name; 2468 CFX_WideString name;
2470 name = pField->GetUnicodeTextBy("T"); 2469 name = pField->GetUnicodeTextBy("T");
2471 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name); 2470 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name);
2472 CFX_ByteString csBValue = pField->GetStringBy("V"); 2471 CFX_ByteString csBValue = pField->GetStringBy("V");
2473 CFX_WideString csWValue = PDF_DecodeText(csBValue); 2472 CFX_WideString csWValue = PDF_DecodeText(csBValue);
2474 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue); 2473 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue);
2475 2474
2476 fdfEncodedData = fdfEncodedData << name_b.GetBuffer(name_b.GetLength()); 2475 fdfEncodedData << name_b.GetBuffer(name_b.GetLength());
2477 name_b.ReleaseBuffer(); 2476 name_b.ReleaseBuffer();
2478 fdfEncodedData = fdfEncodedData << "="; 2477 fdfEncodedData << "=";
2479 fdfEncodedData = fdfEncodedData 2478 fdfEncodedData << csValue_b.GetBuffer(csValue_b.GetLength());
2480 << csValue_b.GetBuffer(csValue_b.GetLength());
2481 csValue_b.ReleaseBuffer(); 2479 csValue_b.ReleaseBuffer();
2482 if (i != pFields->GetCount() - 1) 2480 if (i != pFields->GetCount() - 1)
2483 fdfEncodedData = fdfEncodedData << "&"; 2481 fdfEncodedData << "&";
2484 } 2482 }
2485 2483
2486 nBufSize = fdfEncodedData.GetLength(); 2484 nBufSize = fdfEncodedData.GetLength();
2487 pBuf = FX_Alloc(uint8_t, nBufSize); 2485 pBuf = FX_Alloc(uint8_t, nBufSize);
2488 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); 2486 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize);
2489 } 2487 }
2490 return TRUE; 2488 return TRUE;
2491 } 2489 }
2492 2490
2493 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( 2491 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2875 break; 2873 break;
2876 } 2874 }
2877 } 2875 }
2878 } 2876 }
2879 2877
2880 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { 2878 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) {
2881 CPDF_Rect rcAnnot; 2879 CPDF_Rect rcAnnot;
2882 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); 2880 pAnnot->GetPDFAnnot()->GetRect(rcAnnot);
2883 return rcAnnot; 2881 return rcAnnot;
2884 } 2882 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_buffer.cpp ('k') | xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698