From 54d2b618ec3111192511d794d1195866e12b78f6 Mon Sep 17 00:00:00 2001 From: "bbudge@chromium.org" Date: Thu, 21 Mar 2013 03:16:23 +0000 Subject: Modify content::GetFontTable to allow clients to control what is read. This will be used in an upcoming PPAPI Font API. This adds an offset, and changes the semantics so that the function will only read as much data as the client requests. Before, the function would fail if the buffer wasn't big enough. BUG=79375 Review URL: https://chromiumcodereview.appspot.com/12433021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189505 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/pepper/pepper_flash_font_file_host.cc | 5 +++-- chrome/renderer/pepper/ppb_pdf_impl.cc | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'chrome/renderer') diff --git a/chrome/renderer/pepper/pepper_flash_font_file_host.cc b/chrome/renderer/pepper/pepper_flash_font_file_host.cc index b427265..524c227 100644 --- a/chrome/renderer/pepper/pepper_flash_font_file_host.cc +++ b/chrome/renderer/pepper/pepper_flash_font_file_host.cc @@ -57,11 +57,12 @@ int32_t PepperFlashFontFileHost::OnGetFontTable( #if defined(OS_LINUX) || defined(OS_OPENBSD) if (fd_ != -1) { size_t length = 0; - if (content::GetFontTable(fd_, table, NULL, &length)) { + if (content::GetFontTable(fd_, table, 0 /* offset */, NULL, &length)) { contents.resize(length); uint8_t* contents_ptr = reinterpret_cast(const_cast(contents.c_str())); - if (content::GetFontTable(fd_, table, contents_ptr, &length)) { + if (content::GetFontTable(fd_, table, 0 /* offset */, + contents_ptr, &length)) { result = PP_OK; } else { contents.clear(); diff --git a/chrome/renderer/pepper/ppb_pdf_impl.cc b/chrome/renderer/pepper/ppb_pdf_impl.cc index 0198b19..2454c90 100644 --- a/chrome/renderer/pepper/ppb_pdf_impl.cc +++ b/chrome/renderer/pepper/ppb_pdf_impl.cc @@ -6,6 +6,7 @@ #include "base/command_line.h" #include "base/metrics/histogram.h" +#include "base/safe_numerics.h" #include "base/utf_string_conversions.h" #include "build/build_config.h" #include "chrome/common/chrome_switches.h" @@ -61,8 +62,8 @@ class PrivateFontFile : public ppapi::Resource { uint32_t* output_length) { size_t temp_size = static_cast(*output_length); bool rv = content::GetFontTable( - fd_, table, static_cast(output), &temp_size); - *output_length = static_cast(temp_size); + fd_, table, 0 /* offset */, static_cast(output), &temp_size); + *output_length = base::checked_numeric_cast(temp_size); return rv; } -- cgit v1.1