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

Unified Diff: remoting/host/security_key/remote_security_key_message_reader_impl.cc

Issue 1900733002: Fixing a Dr. Memory hang in the remoting_unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing the formatting for the changed files. Created 4 years, 8 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 | remoting/host/security_key/remote_security_key_message_reader_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/security_key/remote_security_key_message_reader_impl.cc
diff --git a/remoting/host/security_key/remote_security_key_message_reader_impl.cc b/remoting/host/security_key/remote_security_key_message_reader_impl.cc
index 55c4061d1af7b7366f307885e3fb5ce0e04ac87f..618ebfe029988d9e7a26ccc97954af93fca5cba8 100644
--- a/remoting/host/security_key/remote_security_key_message_reader_impl.cc
+++ b/remoting/host/security_key/remote_security_key_message_reader_impl.cc
@@ -85,16 +85,29 @@ void RemoteSecurityKeyMessageReaderImpl::ReadMessage() {
return;
}
+ // Read the message type.
std::string message_data(total_message_size_bytes, '\0');
- read_result = read_stream_.ReadAtCurrentPos(string_as_array(&message_data),
- total_message_size_bytes);
- // The static cast is safe as we know the value is smaller than max int.
- if (read_result != static_cast<int>(total_message_size_bytes)) {
- LOG(ERROR) << "Failed to read message: " << read_result;
+ read_result =
+ read_stream_.ReadAtCurrentPos(string_as_array(&message_data), 1);
+ if (read_result != 1) {
+ LOG(ERROR) << "Failed to read message type: " << read_result;
NotifyError();
return;
}
+ // Read the message payload, if one exists.
+ if (total_message_size_bytes > 1) {
+ uint32_t remaining_bytes = total_message_size_bytes - 1;
+ read_result =
+ read_stream_.ReadAtCurrentPos(&message_data[1], remaining_bytes);
Sergey Ulanov 2016/04/18 18:57:32 I don't understand why you need to call ReadAtCurr
joedow 2016/04/19 17:28:10 This is a good point, my workaround isn't robust e
+ // The static cast is safe as we know the value is smaller than max int.
+ if (read_result != static_cast<int>(remaining_bytes)) {
+ LOG(ERROR) << "Failed to read message payload: " << read_result;
+ NotifyError();
+ return;
+ }
+ }
+
std::unique_ptr<SecurityKeyMessage> message(new SecurityKeyMessage());
if (!message->ParseMessage(message_data)) {
LOG(ERROR) << "Invalid message data received.";
« no previous file with comments | « no previous file | remoting/host/security_key/remote_security_key_message_reader_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698