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

Side by Side Diff: src/wasm/module-decoder.cc

Issue 2656713003: [wasm] Fix check failure on invalid name section (Closed)
Patch Set: Created 3 years, 11 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 | test/mjsunit/regress/wasm/regression-684858.js » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/wasm/module-decoder.h" 5 #include "src/wasm/module-decoder.h"
6 6
7 #include "src/base/functional.h" 7 #include "src/base/functional.h"
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/flags.h" 9 #include "src/flags.h"
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 // TODO(titzer): find a way to report name errors as warnings. 613 // TODO(titzer): find a way to report name errors as warnings.
614 // Use an inner decoder so that errors don't fail the outer decoder. 614 // Use an inner decoder so that errors don't fail the outer decoder.
615 Decoder inner(start_, pc_, end_); 615 Decoder inner(start_, pc_, end_);
616 uint32_t functions_count = inner.consume_u32v("functions count"); 616 uint32_t functions_count = inner.consume_u32v("functions count");
617 617
618 for (uint32_t i = 0; inner.ok() && i < functions_count; ++i) { 618 for (uint32_t i = 0; inner.ok() && i < functions_count; ++i) {
619 uint32_t function_name_length = 0; 619 uint32_t function_name_length = 0;
620 uint32_t name_offset = 620 uint32_t name_offset =
621 consume_string(inner, &function_name_length, false); 621 consume_string(inner, &function_name_length, false);
622 uint32_t func_index = i; 622 uint32_t func_index = i;
623 if (func_index < module->functions.size()) { 623 if (inner.ok() && func_index < module->functions.size()) {
bradn 2017/01/25 11:18:05 Ah I see. Kind of goofy how this section is speced
titzer 2017/01/25 11:53:29 I'm OK with "best effort" if we just leave the nam
Mircea Trofin 2017/01/25 15:58:51 We should take a stance though and propose a PR on
Mircea Trofin 2017/01/25 16:42:00 Followed up with this PR, please take a look (incl
624 module->functions[func_index].name_offset = name_offset; 624 module->functions[func_index].name_offset = name_offset;
625 module->functions[func_index].name_length = function_name_length; 625 module->functions[func_index].name_length = function_name_length;
626 } 626 }
627 627
628 uint32_t local_names_count = inner.consume_u32v("local names count"); 628 uint32_t local_names_count = inner.consume_u32v("local names count");
629 for (uint32_t j = 0; ok() && j < local_names_count; j++) { 629 for (uint32_t j = 0; ok() && j < local_names_count; j++) {
630 uint32_t length = inner.consume_u32v("string length"); 630 uint32_t length = inner.consume_u32v("string length");
631 inner.consume_bytes(length, "string"); 631 inner.consume_bytes(length, "string");
632 } 632 }
633 } 633 }
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 result.push_back({section_start, name_offset, name_length, payload_offset, 1294 result.push_back({section_start, name_offset, name_length, payload_offset,
1295 payload_length, section_length}); 1295 payload_length, section_length});
1296 } 1296 }
1297 1297
1298 return result; 1298 return result;
1299 } 1299 }
1300 1300
1301 } // namespace wasm 1301 } // namespace wasm
1302 } // namespace internal 1302 } // namespace internal
1303 } // namespace v8 1303 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/wasm/regression-684858.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698