| Index: components/nacl/renderer/ppb_nacl_private_impl.cc
|
| diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
|
| index 2623e28b89cf73d3447687dbf6a79dde173ef397..c22e465a5eff38506247d1b69e55522292879ae5 100644
|
| --- a/components/nacl/renderer/ppb_nacl_private_impl.cc
|
| +++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
|
| @@ -1114,16 +1114,42 @@ PP_Bool GetPNaClResourceInfo(PP_Instance instance,
|
| return PP_FALSE;
|
| }
|
|
|
| - const int kBufferSize = 1 << 20;
|
| - scoped_ptr<char[]> buffer(new char[kBufferSize]);
|
| - if (base::ReadPlatformFile(file, 0, buffer.get(), kBufferSize) < 0) {
|
| + base::PlatformFileInfo file_info;
|
| + if (!GetPlatformFileInfo(file, &file_info)) {
|
| load_manager->ReportLoadError(
|
| PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
|
| - std::string("PnaclResources::ReadResourceInfo reading failed for: ") +
|
| + std::string("GetPNaClResourceInfo, GetFileInfo failed for: ") +
|
| filename);
|
| return PP_FALSE;
|
| }
|
|
|
| + if (file_info.size > 1 << 20) {
|
| + load_manager->ReportLoadError(
|
| + PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
|
| + std::string("GetPNaClResourceInfo, file too large: ") + filename);
|
| + return PP_FALSE;
|
| + }
|
| +
|
| + scoped_ptr<char[]> buffer(new char[file_info.size + 1]);
|
| + if (buffer.get() == NULL) {
|
| + load_manager->ReportLoadError(
|
| + PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
|
| + std::string("GetPNaClResourceInfo, couldn't allocate for: ") +
|
| + filename);
|
| + return PP_FALSE;
|
| + }
|
| +
|
| + int rc = base::ReadPlatformFile(file, 0, buffer.get(), file_info.size);
|
| + if (rc < 0) {
|
| + load_manager->ReportLoadError(
|
| + PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
|
| + std::string("GetPNaClResourceInfo, reading failed for: ") + filename);
|
| + return PP_FALSE;
|
| + }
|
| +
|
| + // Null-terminate the bytes we we read from the file.
|
| + buffer.get()[rc] = 0;
|
| +
|
| // Expect the JSON file to contain a top-level object (dictionary).
|
| Json::Reader json_reader;
|
| Json::Value json_data;
|
|
|