mirror of
https://github.com/apple/pkl.git
synced 2026-09-13 13:21:47 +02:00
Enforce max collection sizes when decoding pkl-binary (#1831)
This commit is contained in:
@@ -230,4 +230,35 @@ class PklBinaryDecoderTest {
|
||||
"Unexpected blank typealias module URI",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `decode collections too large`() {
|
||||
assertExceptionCauseMessageContains(
|
||||
byteArrayOf(0x93.toByte(), PklBinaryCode.OBJECT.code) +
|
||||
strFoo +
|
||||
strFoo +
|
||||
byteArrayOf(0xdd.toByte(), 0, 1, 0, 0),
|
||||
"Unable to decode object of length 65536, exceeded maximum collection size",
|
||||
)
|
||||
assertExceptionCauseMessageContains(
|
||||
byteArrayOf(0x93.toByte(), PklBinaryCode.MAP.code, 0xdf.toByte(), 0, 1, 0, 0),
|
||||
"Unable to decode map of length 65536, exceeded maximum collection size",
|
||||
)
|
||||
assertExceptionCauseMessageContains(
|
||||
byteArrayOf(0x93.toByte(), PklBinaryCode.MAPPING.code, 0xdf.toByte(), 0, 1, 0, 0),
|
||||
"Unable to decode mapping of length 65536, exceeded maximum collection size",
|
||||
)
|
||||
assertExceptionCauseMessageContains(
|
||||
byteArrayOf(0x93.toByte(), PklBinaryCode.LIST.code, 0xdd.toByte(), 0, 1, 0, 0),
|
||||
"Unable to decode list of length 65536, exceeded maximum collection size",
|
||||
)
|
||||
assertExceptionCauseMessageContains(
|
||||
byteArrayOf(0x93.toByte(), PklBinaryCode.LISTING.code, 0xdd.toByte(), 0, 1, 0, 0),
|
||||
"Unable to decode listing of length 65536, exceeded maximum collection size",
|
||||
)
|
||||
assertExceptionCauseMessageContains(
|
||||
byteArrayOf(0x93.toByte(), PklBinaryCode.SET.code, 0xdd.toByte(), 0, 1, 0, 0),
|
||||
"Unable to decode set of length 65536, exceeded maximum collection size",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user