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

Side by Side Diff: mojo/edk/system/data_pipe_consumer_dispatcher.cc

Issue 2034183002: [mojo-edk] Add some buffer checks and fix UAF on NodeChannel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | mojo/edk/system/data_pipe_producer_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/edk/system/data_pipe_consumer_dispatcher.h" 5 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } 528 }
529 529
530 if (port_status.has_messages && !in_transit_) { 530 if (port_status.has_messages && !in_transit_) {
531 ports::ScopedMessage message; 531 ports::ScopedMessage message;
532 do { 532 do {
533 int rv = node_controller_->node()->GetMessageIf(control_port_, nullptr, 533 int rv = node_controller_->node()->GetMessageIf(control_port_, nullptr,
534 &message); 534 &message);
535 if (rv != ports::OK) 535 if (rv != ports::OK)
536 peer_closed_ = true; 536 peer_closed_ = true;
537 if (message) { 537 if (message) {
538 if (message->num_payload_bytes() < sizeof(DataPipeControlMessage)) {
539 peer_closed_ = true;
540 break;
541 }
542
538 const DataPipeControlMessage* m = 543 const DataPipeControlMessage* m =
539 static_cast<const DataPipeControlMessage*>( 544 static_cast<const DataPipeControlMessage*>(
540 message->payload_bytes()); 545 message->payload_bytes());
541 546
542 if (m->command != DataPipeCommand::DATA_WAS_WRITTEN) { 547 if (m->command != DataPipeCommand::DATA_WAS_WRITTEN) {
543 DLOG(ERROR) << "Unexpected control message from producer."; 548 DLOG(ERROR) << "Unexpected control message from producer.";
544 peer_closed_ = true; 549 peer_closed_ = true;
545 break; 550 break;
546 } 551 }
547 552
(...skipping 14 matching lines...) Expand all
562 } 567 }
563 568
564 if (peer_closed_ != was_peer_closed || 569 if (peer_closed_ != was_peer_closed ||
565 bytes_available_ != previous_bytes_available) { 570 bytes_available_ != previous_bytes_available) {
566 awakable_list_.AwakeForStateChange(GetHandleSignalsStateNoLock()); 571 awakable_list_.AwakeForStateChange(GetHandleSignalsStateNoLock());
567 } 572 }
568 } 573 }
569 574
570 } // namespace edk 575 } // namespace edk
571 } // namespace mojo 576 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/edk/system/data_pipe_producer_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698