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

Side by Side Diff: runtime/bin/eventhandler_linux.cc

Issue 10243003: Fix invalid pointer arithmetic in Linux and MacOS event handler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/eventhandler_macos.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/eventhandler.h" 5 #include "bin/eventhandler.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 if (result != kInterruptMessageSize) { 161 if (result != kInterruptMessageSize) {
162 if (result == -1) { 162 if (result == -1) {
163 perror("Interrupt message failure:"); 163 perror("Interrupt message failure:");
164 } 164 }
165 FATAL1("Interrupt message failure. Wrote %d bytes.", result); 165 FATAL1("Interrupt message failure. Wrote %d bytes.", result);
166 } 166 }
167 } 167 }
168 168
169 169
170 bool EventHandlerImplementation::GetInterruptMessage(InterruptMessage* msg) { 170 bool EventHandlerImplementation::GetInterruptMessage(InterruptMessage* msg) {
171 char* dst = reinterpret_cast<char*>(msg);
171 int total_read = 0; 172 int total_read = 0;
172 int bytes_read = 173 int bytes_read =
173 TEMP_FAILURE_RETRY(read(interrupt_fds_[0], msg, kInterruptMessageSize)); 174 TEMP_FAILURE_RETRY(read(interrupt_fds_[0], dst, kInterruptMessageSize));
174 if (bytes_read < 0) { 175 if (bytes_read < 0) {
175 return false; 176 return false;
176 } 177 }
177 total_read = bytes_read; 178 total_read = bytes_read;
178 while (total_read < kInterruptMessageSize) { 179 while (total_read < kInterruptMessageSize) {
179 bytes_read = TEMP_FAILURE_RETRY(read(interrupt_fds_[0], 180 bytes_read = TEMP_FAILURE_RETRY(read(interrupt_fds_[0],
180 msg + total_read, 181 dst + total_read,
181 kInterruptMessageSize - total_read)); 182 kInterruptMessageSize - total_read));
182 if (bytes_read > 0) { 183 if (bytes_read > 0) {
183 total_read = total_read + bytes_read; 184 total_read = total_read + bytes_read;
184 } 185 }
185 } 186 }
186 return (total_read == kInterruptMessageSize) ? true : false; 187 return (total_read == kInterruptMessageSize) ? true : false;
187 } 188 }
188 189
189 void EventHandlerImplementation::HandleInterruptFd() { 190 void EventHandlerImplementation::HandleInterruptFd() {
190 InterruptMessage msg; 191 InterruptMessage msg;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { 411 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) {
411 // The hashmap does not support keys with value 0. 412 // The hashmap does not support keys with value 0.
412 return reinterpret_cast<void*>(fd + 1); 413 return reinterpret_cast<void*>(fd + 1);
413 } 414 }
414 415
415 416
416 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 417 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
417 // The hashmap does not support keys with value 0. 418 // The hashmap does not support keys with value 0.
418 return dart::Utils::WordHash(fd + 1); 419 return dart::Utils::WordHash(fd + 1);
419 } 420 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698