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

Unified Diff: net/url_request/url_request_file_job.cc

Issue 2786583002: chromeos: Check both original and absolute paths for file: scheme (Closed)
Patch Set: remove dcheck Created 3 years, 7 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 | « net/url_request/url_request_file_job.h ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_file_job.cc
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index 4924e02349100a852f8c4499472ea42bef3feb6b..7d68f087f57992d06f2c69ca78fdf123e281f54f 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -196,6 +196,12 @@ std::unique_ptr<SourceStream> URLRequestFileJob::SetUpSourceStream() {
return GzipSourceStream::Create(std::move(source), SourceStream::TYPE_GZIP);
}
+bool URLRequestFileJob::CanAccessFile(const base::FilePath& original_path,
+ const base::FilePath& absolute_path) {
+ return !network_delegate() || network_delegate()->CanAccessFile(
+ *request(), original_path, absolute_path);
+}
+
void URLRequestFileJob::FetchMetaInfo(const base::FilePath& file_path,
FileMetaInfo* meta_info) {
base::File::Info file_info;
@@ -208,6 +214,7 @@ void URLRequestFileJob::FetchMetaInfo(const base::FilePath& file_path,
// done in WorkerPool.
meta_info->mime_type_result = GetMimeTypeFromFile(file_path,
&meta_info->mime_type);
+ meta_info->absolute_path = base::MakeAbsoluteFilePath(file_path);
}
void URLRequestFileJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {
@@ -230,6 +237,11 @@ void URLRequestFileJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {
return;
}
+ if (!CanAccessFile(file_path_, meta_info->absolute_path)) {
+ DidOpen(ERR_ACCESS_DENIED);
+ return;
+ }
+
int flags = base::File::FLAG_OPEN |
base::File::FLAG_READ |
base::File::FLAG_ASYNC;
« no previous file with comments | « net/url_request/url_request_file_job.h ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698