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

Unified Diff: content/browser/blob_storage/blob_dispatcher_host.cc

Issue 2378253002: BlobDispatcherHost: don't rely on NOTREACHED() checks in ParamTraits::Read (Closed)
Patch Set: notreached Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/common/resource_messages.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/blob_storage/blob_dispatcher_host.cc
diff --git a/content/browser/blob_storage/blob_dispatcher_host.cc b/content/browser/blob_storage/blob_dispatcher_host.cc
index 4f2ed8439f15ee20201f45bef45f5b836ccfb62f..301d567ff1b027c66ee426ed07a8da53a1a203c9 100644
--- a/content/browser/blob_storage/blob_dispatcher_host.cc
+++ b/content/browser/blob_storage/blob_dispatcher_host.cc
@@ -150,26 +150,46 @@ void BlobDispatcherHost::OnStartBuildingBlob(
ChildProcessSecurityPolicyImpl* security_policy =
ChildProcessSecurityPolicyImpl::GetInstance();
for (const DataElement& item : descriptions) {
- if (item.type() == storage::DataElement::TYPE_FILE_FILESYSTEM) {
- FileSystemURL filesystem_url(
- file_system_context_->CrackURL(item.filesystem_url()));
- if (!FileSystemURLIsValid(file_system_context_.get(), filesystem_url) ||
- !security_policy->CanReadFileSystemFile(process_id_,
- filesystem_url)) {
- async_builder_.CancelBuildingBlob(
- uuid, IPCBlobCreationCancelCode::FILE_WRITE_FAILED, context);
- Send(new BlobStorageMsg_CancelBuildingBlob(
- uuid, IPCBlobCreationCancelCode::FILE_WRITE_FAILED));
- return;
+ // For each source object that provides the data for the blob, ensure that
+ // this process has permission to read it.
+ switch (item.type()) {
+ case storage::DataElement::TYPE_FILE_FILESYSTEM: {
+ FileSystemURL filesystem_url(
+ file_system_context_->CrackURL(item.filesystem_url()));
+ if (!FileSystemURLIsValid(file_system_context_.get(), filesystem_url) ||
+ !security_policy->CanReadFileSystemFile(process_id_,
+ filesystem_url)) {
+ async_builder_.CancelBuildingBlob(
+ uuid, IPCBlobCreationCancelCode::FILE_WRITE_FAILED, context);
+ Send(new BlobStorageMsg_CancelBuildingBlob(
+ uuid, IPCBlobCreationCancelCode::FILE_WRITE_FAILED));
+ return;
+ }
+ break;
+ }
+ case storage::DataElement::TYPE_FILE: {
+ if (!security_policy->CanReadFile(process_id_, item.path())) {
+ async_builder_.CancelBuildingBlob(
+ uuid, IPCBlobCreationCancelCode::FILE_WRITE_FAILED, context);
+ Send(new BlobStorageMsg_CancelBuildingBlob(
+ uuid, IPCBlobCreationCancelCode::FILE_WRITE_FAILED));
+ return;
+ }
+ break;
+ }
+ case storage::DataElement::TYPE_BLOB:
+ case storage::DataElement::TYPE_BYTES_DESCRIPTION:
+ case storage::DataElement::TYPE_BYTES: {
+ // Bytes are already in hand; no need to check read permission.
+ // TODO(nick): For TYPE_BLOB, can we actually get here for blobs
+ // originally created by other processes? If so, is that cool?
+ break;
+ }
+ case storage::DataElement::TYPE_UNKNOWN:
+ case storage::DataElement::TYPE_DISK_CACHE_ENTRY: {
+ NOTREACHED(); // Should have been caught by IPC deserialization.
+ break;
}
- }
- if (item.type() == storage::DataElement::TYPE_FILE &&
- !security_policy->CanReadFile(process_id_, item.path())) {
- async_builder_.CancelBuildingBlob(
- uuid, IPCBlobCreationCancelCode::FILE_WRITE_FAILED, context);
- Send(new BlobStorageMsg_CancelBuildingBlob(
- uuid, IPCBlobCreationCancelCode::FILE_WRITE_FAILED));
- return;
}
}
« no previous file with comments | « no previous file | content/common/resource_messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698