summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormorrita <morrita@chromium.org>2014-09-30 14:25:01 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-30 21:25:20 +0000
commitf7ef6dd233c8c0b7d237e35476c44b2c26d2bab0 (patch)
tree0650b40609ffacbaabccc52ae8ea9aad42238fb8
parentd5db0641e6b4d9bc9ff3df3dd46b44734a73acb9 (diff)
downloadchromium_src-f7ef6dd233c8c0b7d237e35476c44b2c26d2bab0.zip
chromium_src-f7ef6dd233c8c0b7d237e35476c44b2c26d2bab0.tar.gz
chromium_src-f7ef6dd233c8c0b7d237e35476c44b2c26d2bab0.tar.bz2
mojo::RawChannelWin: Use GetOverlappedResult() to retrive read bytes.
The MSDN document suggests that with overlapped I/O, |lpNumberOfBytesRead| parameter of ReadFile() API isn't reliable and shouldn't be used. GetOverlappedResult() should be used instead, according to the doc. See: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365467(v=vs.85).aspx This is a speculative crash fix for crbug.com/41509. The crash happens only on Windows. The report also implies that there might be some message duplication.It is possible if the value of |lpNumberOfBytesRead| is wrong. BUG=415059 R=viettrungluu@chromium.org Review URL: https://codereview.chromium.org/616043003 Cr-Commit-Position: refs/heads/master@{#297500}
-rw-r--r--mojo/system/raw_channel_win.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/mojo/system/raw_channel_win.cc b/mojo/system/raw_channel_win.cc
index 1090038..72cec16 100644
--- a/mojo/system/raw_channel_win.cc
+++ b/mojo/system/raw_channel_win.cc
@@ -371,14 +371,12 @@ RawChannel::IOResult RawChannelWin::Read(size_t* bytes_read) {
size_t bytes_to_read = 0;
read_buffer()->GetBuffer(&buffer, &bytes_to_read);
- DWORD bytes_read_dword = 0;
BOOL result = ReadFile(io_handler_->handle(),
buffer,
static_cast<DWORD>(bytes_to_read),
- &bytes_read_dword,
+ nullptr,
&io_handler_->read_context()->overlapped);
if (!result) {
- DCHECK_EQ(bytes_read_dword, 0u);
DWORD error = GetLastError();
if (error == ERROR_BROKEN_PIPE)
return IO_FAILED_SHUTDOWN;
@@ -389,6 +387,13 @@ RawChannel::IOResult RawChannelWin::Read(size_t* bytes_read) {
}
if (result && skip_completion_port_on_success_) {
+ DWORD bytes_read_dword = 0;
+ BOOL get_size_result =
+ GetOverlappedResult(io_handler_->handle(),
+ &io_handler_->read_context()->overlapped,
+ &bytes_read_dword,
+ FALSE);
+ DPCHECK(get_size_result);
*bytes_read = bytes_read_dword;
return IO_SUCCEEDED;
}