blob: 054c55456a611ef1ac71facdb637ce3eee39ee6e [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
encode_failure("StringExceedsLimit") {
// TODO(fxbug.dev/37304) Enforce size bounds in rust
bindings_denylist = [rust, dart],
value = Length2StringWrapper {
length_2_string: "abc", // exceeds the string length
},
err = STRING_TOO_LONG,
}
decode_failure("NonEmptyStringWithNullPtrBody") {
type = StringWrapper,
bytes = {
v1, v2 = [
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // length of string data
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // invalid null pointer to content
],
},
err = NON_EMPTY_STRING_WITH_NULL_BODY,
}
// Test string with a 2^64-1 count, exceeding the 32-bit limit from RFC-0059.
decode_failure("StringCountExceedsLimitByALot") {
// TODO(fxbug.dev/82167): Go and Dart all panic and don't return proper errors.
bindings_denylist = [go, dart],
type = StringWrapper,
bytes = {
v1, v2 = [
num(0xffffffffffffffff):8, // length of string data
repeat(0xff):8, // presence marker
]
},
err = COUNT_EXCEEDS_LIMIT,
}
// Test string with a 2^32 count, exceeding the 32-bit limit from RFC-0059.
decode_failure("StringCountExceedsLimitByOne") {
// TODO(fxbug.dev/82167): Go and Dart all panic and don't return proper errors.
bindings_denylist = [go, dart],
type = StringWrapper,
bytes = {
v1, v2 = [
num(0x100000000):8, // length of string data
repeat(0xff):8, // presence marker
]
},
err = COUNT_EXCEEDS_LIMIT,
}
// Test string with count that exceeds the total message size. Bindings should
// explicitly check for this to avoid allocating huge strings before failing.
decode_failure("StringCountExceedsTotalMessageSize") {
type = StringWrapper,
bytes = {
v1, v2 = [
num(25):8, // length of string data (invalid, should be 8)
repeat(0xff):8, // presence marker
repeat(0xab):8, // string data
]
},
err = TOO_FEW_BYTES,
}
// Test string with count that exceeds the remainder of the message size.
// Bindings should not explicitly check for this, but it should still fail.
decode_failure("StringCountExceedsRemainingMessageSize") {
type = StringWrapper,
bytes = {
v1, v2 = [
num(9):8, // length of string data (invalid, should be 8)
repeat(0xff):8, // presence marker
repeat(0xab):8, // string data
]
},
err = TOO_FEW_BYTES,
}