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

Side by Side Diff: runtime/bin/eventhandler_macos.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 | « runtime/bin/eventhandler_linux.cc ('k') | no next file » | 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (result != kInterruptMessageSize) { 173 if (result != kInterruptMessageSize) {
174 if (result == -1) { 174 if (result == -1) {
175 perror("Interrupt message failure:"); 175 perror("Interrupt message failure:");
176 } 176 }
177 FATAL1("Interrupt message failure. Wrote %d bytes.", result); 177 FATAL1("Interrupt message failure. Wrote %d bytes.", result);
178 } 178 }
179 } 179 }
180 180
181 181
182 bool EventHandlerImplementation::GetInterruptMessage(InterruptMessage* msg) { 182 bool EventHandlerImplementation::GetInterruptMessage(InterruptMessage* msg) {
183 char* dst = reinterpret_cast<char*>(msg);
183 int total_read = 0; 184 int total_read = 0;
184 int bytes_read = 185 int bytes_read =
185 TEMP_FAILURE_RETRY(read(interrupt_fds_[0], msg, kInterruptMessageSize)); 186 TEMP_FAILURE_RETRY(read(interrupt_fds_[0], dst, kInterruptMessageSize));
186 if (bytes_read < 0) { 187 if (bytes_read < 0) {
187 return false; 188 return false;
188 } 189 }
189 total_read = bytes_read; 190 total_read = bytes_read;
190 while (total_read < kInterruptMessageSize) { 191 while (total_read < kInterruptMessageSize) {
191 bytes_read = TEMP_FAILURE_RETRY(read(interrupt_fds_[0], 192 bytes_read = TEMP_FAILURE_RETRY(read(interrupt_fds_[0],
192 msg + total_read, 193 dst + total_read,
193 kInterruptMessageSize - total_read)); 194 kInterruptMessageSize - total_read));
194 if (bytes_read > 0) { 195 if (bytes_read > 0) {
195 total_read = total_read + bytes_read; 196 total_read = total_read + bytes_read;
196 } 197 }
197 } 198 }
198 return (total_read == kInterruptMessageSize) ? true : false; 199 return (total_read == kInterruptMessageSize) ? true : false;
199 } 200 }
200 201
201 void EventHandlerImplementation::HandleInterruptFd() { 202 void EventHandlerImplementation::HandleInterruptFd() {
202 InterruptMessage msg; 203 InterruptMessage msg;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { 404 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) {
404 // The hashmap does not support keys with value 0. 405 // The hashmap does not support keys with value 0.
405 return reinterpret_cast<void*>(fd + 1); 406 return reinterpret_cast<void*>(fd + 1);
406 } 407 }
407 408
408 409
409 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 410 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
410 // The hashmap does not support keys with value 0. 411 // The hashmap does not support keys with value 0.
411 return dart::Utils::WordHash(fd + 1); 412 return dart::Utils::WordHash(fd + 1);
412 } 413 }
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698