[wasm] Improve error message in the streaming decoder
Bug: chromium:1213097 Change-Id: If768725a5645b7d21f59845692ca5491e8674bfa Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2940896 Reviewed-by: Clemens Backes <clemensb@chromium.org> Commit-Queue: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#74964}
This commit is contained in:
parent
89ec29a117
commit
ae2f476c79
@ -462,7 +462,7 @@ class AsyncStreamingDecoder::DecodeFunctionLength : public DecodeVarInt32 {
|
||||
explicit DecodeFunctionLength(SectionBuffer* section_buffer,
|
||||
size_t buffer_offset,
|
||||
size_t num_remaining_functions)
|
||||
: DecodeVarInt32(kV8MaxWasmFunctionSize, "body size"),
|
||||
: DecodeVarInt32(kV8MaxWasmFunctionSize, "function body size"),
|
||||
section_buffer_(section_buffer),
|
||||
buffer_offset_(buffer_offset),
|
||||
// We are reading a new function, so one function less is remaining.
|
||||
@ -549,8 +549,8 @@ AsyncStreamingDecoder::DecodeVarInt32::Next(AsyncStreamingDecoder* streaming) {
|
||||
|
||||
if (value_ > max_value_) {
|
||||
std::ostringstream oss;
|
||||
oss << "function size > maximum function size: " << value_ << " < "
|
||||
<< max_value_;
|
||||
oss << "The value " << value_ << " for " << field_name_
|
||||
<< " exceeds the maximum allowed value of " << max_value_;
|
||||
return streaming->Error(oss.str());
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ function testErrorPosition(bytes, pos, message) {
|
||||
bytes.emit_u8(kTypeSectionCode);
|
||||
bytes.emit_u32v(0xffffff23);
|
||||
let pos = bytes.length - 1;
|
||||
testErrorPositionAsyncOnly(bytes, pos, 'maximum function size');
|
||||
testErrorPositionAsyncOnly(bytes, pos, 'section length');
|
||||
})();
|
||||
|
||||
(function testFunctionsCountInvalidVarint() {
|
||||
@ -110,7 +110,7 @@ function testErrorPosition(bytes, pos, message) {
|
||||
bytes.emit_u32v(0xffffff23);
|
||||
|
||||
let pos = bytes.length - 1;
|
||||
testErrorPositionAsyncOnly(bytes, pos, 'maximum function size');
|
||||
testErrorPositionAsyncOnly(bytes, pos, 'functions count');
|
||||
})();
|
||||
|
||||
(function testFunctionsCountDoesNotMatch() {
|
||||
@ -163,7 +163,7 @@ function testErrorPosition(bytes, pos, message) {
|
||||
bytes.emit_bytes([0x80, 0x80, 0x80, 0x80, 0x80, 0x00]);
|
||||
|
||||
let pos = bytes.length - 1 - 1;
|
||||
testErrorPositionAsyncOnly(bytes, pos, 'expected body size');
|
||||
testErrorPositionAsyncOnly(bytes, pos, 'function body size');
|
||||
})();
|
||||
|
||||
(function testBodySizeTooBig() {
|
||||
@ -192,7 +192,7 @@ function testErrorPosition(bytes, pos, message) {
|
||||
bytes.emit_u32v(0xffffff23);
|
||||
|
||||
let pos = bytes.length - 1;
|
||||
testErrorPositionAsyncOnly(bytes, pos, 'maximum function size');
|
||||
testErrorPositionAsyncOnly(bytes, pos, 'function body size');
|
||||
})();
|
||||
|
||||
(function testBodySizeDoesNotFit() {
|
||||
|
Loading…
Reference in New Issue
Block a user