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

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

Issue 307653002: Fix a security issue in FPDF_GetMetaText (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 6 years, 6 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 | « no previous file | no next file » | 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/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fpdfdoc.h" 8 #include "../include/fpdfdoc.h"
9 9
10 static int this_module = 0; 10 static int this_module = 0;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 CPDF_Document* pDoc = (CPDF_Document*)doc; 242 CPDF_Document* pDoc = (CPDF_Document*)doc;
243 // Get info dictionary 243 // Get info dictionary
244 CPDF_Dictionary* pInfo = pDoc->GetInfo(); 244 CPDF_Dictionary* pInfo = pDoc->GetInfo();
245 if (pInfo == NULL) return 0; 245 if (pInfo == NULL) return 0;
246 246
247 CFX_WideString text = pInfo->GetUnicodeText(tag); 247 CFX_WideString text = pInfo->GetUnicodeText(tag);
248 248
249 // Use UTF-16LE encoding 249 // Use UTF-16LE encoding
250 CFX_ByteString bstr = text.UTF16LE_Encode(); 250 CFX_ByteString bstr = text.UTF16LE_Encode();
251 unsigned long len = bstr.GetLength(); 251 unsigned long len = bstr.GetLength();
252 » if (buffer != NULL || buflen >= len+2) { 252 » if (buffer != NULL && buflen >= len+2) {
253 FXSYS_memcpy(buffer, (FX_LPCSTR)bstr, len); 253 FXSYS_memcpy(buffer, (FX_LPCSTR)bstr, len);
254 // use double zero as trailer 254 // use double zero as trailer
255 ((FX_BYTE*)buffer)[len] = ((FX_BYTE*)buffer)[len+1] = 0; 255 ((FX_BYTE*)buffer)[len] = ((FX_BYTE*)buffer)[len+1] = 0;
256 } 256 }
257 return len+2; 257 return len+2;
258 } 258 }
259 259
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698