- All Implemented Interfaces:
- Test
public class DefiniteLengthAllocationTest
extends SimpleTest
Regression coverage for the definite-length materialization allocation guard in
DefiniteLengthInputStream.toByteArray(). When ASN1InputStream wraps a raw
(non-array, non-file) stream, the per-object limit falls back to Runtime.maxMemory
(StreamUtil.findLimit), so allocating the full declared length up front let a short
crafted header - an OCTET STRING declaring a near-heap length with no body - drive an
OutOfMemoryError before any data was read (CWE-789). The buffer is now grown as bytes actually
arrive: a short input allocates only a bounded working buffer, a well-formed object still
materializes correctly, and a truncated object still fails with the established
"DEF length ... object truncated by ..." EOFException.