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

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

Issue 2248213003: Merged: [wasm] Require global names to be validate UTF-8. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5.3
Patch Set: Created 4 years, 4 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 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/macro-assembler.h" 9 #include "src/macro-assembler.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 private: 472 private:
473 Zone* module_zone; 473 Zone* module_zone;
474 ModuleResult result_; 474 ModuleResult result_;
475 ModuleOrigin origin_; 475 ModuleOrigin origin_;
476 476
477 uint32_t off(const byte* ptr) { return static_cast<uint32_t>(ptr - start_); } 477 uint32_t off(const byte* ptr) { return static_cast<uint32_t>(ptr - start_); }
478 478
479 // Decodes a single global entry inside a module starting at {pc_}. 479 // Decodes a single global entry inside a module starting at {pc_}.
480 void DecodeGlobalInModule(WasmGlobal* global) { 480 void DecodeGlobalInModule(WasmGlobal* global) {
481 global->name_offset = consume_string(&global->name_length, false); 481 global->name_offset = consume_string(&global->name_length, false);
482 DCHECK(unibrow::Utf8::Validate(start_ + global->name_offset, 482 if(!unibrow::Utf8::Validate(start_ + global->name_offset,
483 global->name_length)); 483 global->name_length)) {
484 error("global name is not valid utf8");
485 }
484 global->type = mem_type(); 486 global->type = mem_type();
485 global->offset = 0; 487 global->offset = 0;
486 global->exported = consume_u8("exported") != 0; 488 global->exported = consume_u8("exported") != 0;
487 } 489 }
488 490
489 bool IsWithinLimit(uint32_t limit, uint32_t offset, uint32_t size) { 491 bool IsWithinLimit(uint32_t limit, uint32_t offset, uint32_t size) {
490 if (offset > limit) return false; 492 if (offset > limit) return false;
491 if ((offset + size) < offset) return false; // overflow 493 if ((offset + size) < offset) return false; // overflow
492 return (offset + size) <= limit; 494 return (offset + size) <= limit;
493 } 495 }
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 decoder.consume_bytes(size); 841 decoder.consume_bytes(size);
840 } 842 }
841 if (decoder.more()) decoder.error("unexpected additional bytes"); 843 if (decoder.more()) decoder.error("unexpected additional bytes");
842 844
843 return decoder.toResult(std::move(table)); 845 return decoder.toResult(std::move(table));
844 } 846 }
845 847
846 } // namespace wasm 848 } // namespace wasm
847 } // namespace internal 849 } // namespace internal
848 } // namespace v8 850 } // namespace v8
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