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

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

Issue 1376973002: Fix for issue 24487951 (heap buffer overflow problem) (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 | 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/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_tools_api.h" 8 #include "include/dart_tools_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 10
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 url, 457 url,
458 library_url, 458 library_url,
459 builtin_lib); 459 builtin_lib);
460 } 460 }
461 461
462 462
463 const uint8_t* DartUtils::SniffForMagicNumber(const uint8_t* text_buffer, 463 const uint8_t* DartUtils::SniffForMagicNumber(const uint8_t* text_buffer,
464 intptr_t* buffer_len, 464 intptr_t* buffer_len,
465 bool* is_snapshot) { 465 bool* is_snapshot) {
466 intptr_t len = sizeof(magic_number); 466 intptr_t len = sizeof(magic_number);
467 if (*buffer_len <= len) {
468 *is_snapshot = false;
469 return text_buffer;
470 }
467 for (intptr_t i = 0; i < len; i++) { 471 for (intptr_t i = 0; i < len; i++) {
468 if (text_buffer[i] != magic_number[i]) { 472 if (text_buffer[i] != magic_number[i]) {
469 *is_snapshot = false; 473 *is_snapshot = false;
470 return text_buffer; 474 return text_buffer;
471 } 475 }
472 } 476 }
473 *is_snapshot = true; 477 *is_snapshot = true;
474 ASSERT(*buffer_len > len); 478 ASSERT(*buffer_len > len);
475 *buffer_len -= len; 479 *buffer_len -= len;
476 return text_buffer + len; 480 return text_buffer + len;
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 new CObjectString(CObject::NewString(os_error->message())); 1240 new CObjectString(CObject::NewString(os_error->message()));
1237 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1241 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1238 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1242 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1239 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1243 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1240 result->SetAt(2, error_message); 1244 result->SetAt(2, error_message);
1241 return result; 1245 return result;
1242 } 1246 }
1243 1247
1244 } // namespace bin 1248 } // namespace bin
1245 } // namespace dart 1249 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698