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

Side by Side Diff: media/blink/resource_multibuffer_data_provider.cc

Issue 1993083002: The cross-origin checks in the multibuffer code are not sufficient, as they only trigger when a red… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium 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 #include "media/blink/resource_multibuffer_data_provider.h" 5 #include "media/blink/resource_multibuffer_data_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 // This test is vital for security! 168 // This test is vital for security!
169 if (cors_mode_ == UrlData::CORS_UNSPECIFIED) { 169 if (cors_mode_ == UrlData::CORS_UNSPECIFIED) {
170 // We allow the redirect if the origin is the same. 170 // We allow the redirect if the origin is the same.
171 if (origin_ != redirects_to_.GetOrigin()) { 171 if (origin_ != redirects_to_.GetOrigin()) {
172 // We also allow the redirect if we don't have any data in the 172 // We also allow the redirect if we don't have any data in the
173 // cache, as that means that no dangerous data mixing can occur. 173 // cache, as that means that no dangerous data mixing can occur.
174 if (url_data_->multibuffer()->map().empty() && fifo_.empty()) 174 if (url_data_->multibuffer()->map().empty() && fifo_.empty())
175 return; 175 return;
176 176
177 active_loader_ = nullptr;
177 url_data_->Fail(); 178 url_data_->Fail();
179 return; // "this" may be deleted now.
178 } 180 }
179 } 181 }
180 } 182 }
181 183
182 void ResourceMultiBufferDataProvider::didSendData( 184 void ResourceMultiBufferDataProvider::didSendData(
183 WebURLLoader* loader, 185 WebURLLoader* loader,
184 unsigned long long bytes_sent, 186 unsigned long long bytes_sent,
185 unsigned long long total_bytes_to_be_sent) { 187 unsigned long long total_bytes_to_be_sent) {
186 NOTIMPLEMENTED(); 188 NOTIMPLEMENTED();
187 } 189 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // to return. 283 // to return.
282 destination_url_data->set_length(content_length); 284 destination_url_data->set_length(content_length);
283 } else if (response.httpStatusCode() == kHttpRangeNotSatisfiable) { 285 } else if (response.httpStatusCode() == kHttpRangeNotSatisfiable) {
284 // Really, we should never request a range that doesn't exist, but 286 // Really, we should never request a range that doesn't exist, but
285 // if we do, let's handle it in a sane way. 287 // if we do, let's handle it in a sane way.
286 // Unsatisfiable range 288 // Unsatisfiable range
287 fifo_.push_back(DataBuffer::CreateEOSBuffer()); 289 fifo_.push_back(DataBuffer::CreateEOSBuffer());
288 destination_url_data->multibuffer()->OnDataProviderEvent(this); 290 destination_url_data->multibuffer()->OnDataProviderEvent(this);
289 return; 291 return;
290 } else { 292 } else {
293 active_loader_ = nullptr;
291 destination_url_data->Fail(); 294 destination_url_data->Fail();
292 return; 295 return; // "this" may be deleted now.
293 } 296 }
294 } else { 297 } else {
295 destination_url_data->set_range_supported(); 298 destination_url_data->set_range_supported();
296 if (content_length != kPositionNotSpecified) { 299 if (content_length != kPositionNotSpecified) {
297 destination_url_data->set_length(content_length + byte_pos()); 300 destination_url_data->set_length(content_length + byte_pos());
298 } 301 }
299 } 302 }
300 303
301 if (url_index) { 304 if (url_index) {
302 destination_url_data = url_index->TryInsert(destination_url_data); 305 destination_url_data = url_index->TryInsert(destination_url_data);
(...skipping 12 matching lines...) Expand all
315 url_data_->multibuffer()->RemoveProvider(this)); 318 url_data_->multibuffer()->RemoveProvider(this));
316 url_data_ = destination_url_data.get(); 319 url_data_ = destination_url_data.get();
317 // Give the ownership to our new owner. 320 // Give the ownership to our new owner.
318 url_data_->multibuffer()->AddProvider(std::move(self)); 321 url_data_->multibuffer()->AddProvider(std::move(self));
319 322
320 // Call callback to let upstream users know about the transfer. 323 // Call callback to let upstream users know about the transfer.
321 // This will merge the data from the two multibuffers and 324 // This will merge the data from the two multibuffers and
322 // cause clients to start using the new UrlData. 325 // cause clients to start using the new UrlData.
323 old_url_data->RedirectTo(destination_url_data); 326 old_url_data->RedirectTo(destination_url_data);
324 } 327 }
328
329 // This test is vital for security!
330 const GURL& original_url = response.wasFetchedViaServiceWorker()
331 ? response.originalURLViaServiceWorker()
332 : response.url();
333 if (!url_data_->ValidateDataOrigin(original_url.GetOrigin())) {
334 active_loader_ = nullptr;
335 url_data_->Fail();
336 return; // "this" may be deleted now.
337 }
325 } 338 }
326 339
327 void ResourceMultiBufferDataProvider::didReceiveData(WebURLLoader* loader, 340 void ResourceMultiBufferDataProvider::didReceiveData(WebURLLoader* loader,
328 const char* data, 341 const char* data,
329 int data_length, 342 int data_length,
330 int encoded_data_length) { 343 int encoded_data_length) {
331 DVLOG(1) << "didReceiveData: " << data_length << " bytes"; 344 DVLOG(1) << "didReceiveData: " << data_length << " bytes";
332 DCHECK(!Available()); 345 DCHECK(!Available());
333 DCHECK(active_loader_); 346 DCHECK(active_loader_);
334 DCHECK_GT(data_length, 0); 347 DCHECK_GT(data_length, 0);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 size < url_data_->length()) { 403 size < url_data_->length()) {
391 if (retries_ < kMaxRetries) { 404 if (retries_ < kMaxRetries) {
392 DVLOG(1) << " Partial data received.... @ pos = " << size; 405 DVLOG(1) << " Partial data received.... @ pos = " << size;
393 retries_++; 406 retries_++;
394 base::MessageLoop::current()->PostDelayedTask( 407 base::MessageLoop::current()->PostDelayedTask(
395 FROM_HERE, base::Bind(&ResourceMultiBufferDataProvider::Start, 408 FROM_HERE, base::Bind(&ResourceMultiBufferDataProvider::Start,
396 weak_factory_.GetWeakPtr()), 409 weak_factory_.GetWeakPtr()),
397 base::TimeDelta::FromMilliseconds(kLoaderPartialRetryDelayMs)); 410 base::TimeDelta::FromMilliseconds(kLoaderPartialRetryDelayMs));
398 return; 411 return;
399 } else { 412 } else {
400 scoped_ptr<ActiveLoader> active_loader = std::move(active_loader_); 413 active_loader_ = nullptr;
401 url_data_->Fail(); 414 url_data_->Fail();
402 return; 415 return; // "this" may be deleted now.
403 } 416 }
404 } 417 }
405 418
406 url_data_->set_length(size); 419 url_data_->set_length(size);
407 fifo_.push_back(DataBuffer::CreateEOSBuffer()); 420 fifo_.push_back(DataBuffer::CreateEOSBuffer());
408 421
409 DCHECK(Available()); 422 DCHECK(Available());
410 url_data_->multibuffer()->OnDataProviderEvent(this); 423 url_data_->multibuffer()->OnDataProviderEvent(this);
411 424
412 // Beware, this object might be deleted here. 425 // Beware, this object might be deleted here.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } 520 }
508 521
509 if (byte_pos() != first_byte_position) { 522 if (byte_pos() != first_byte_position) {
510 return false; 523 return false;
511 } 524 }
512 525
513 return true; 526 return true;
514 } 527 }
515 528
516 } // namespace media 529 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/multibuffer_data_source_unittest.cc ('k') | media/blink/resource_multibuffer_data_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698