Binary decoder returns incorrect data after short stream reads
- Dominant language
- Java
- Stars
- 17
- Forks
- 11
- Avg merge
- 15m
- Merged PRs (30d)
- 1
Description
On master `028751ad`, `BaseBinaryInputReader.checkBuffer()` performs only one stream read before allowing decoding. A valid short read leaves part of the requested value unfilled, so the decoder can silently return incorrect data.
```java
InputStream input = new ByteArrayInputStream(new byte[]{1, 35, 69, 103}) {
@Override
public synchronized int read(byte[] buffer, int offset, int length) {
return super.read(buffer, offset, Math.min(length, 1));
}
};
new FixedBinaryDecoder(input, null, false).decodeInteger();
```
Expected: `0x01234567` (19088743). Actual: `0x01000000` (16777216).
Strings and byte blocks also contain incorrect bytes after fragmented reads. With byte-array input, `checkBuffer()` does not verify the readable length, so `directGetBytes()` can silently pad truncated input with zeros or decode unused buffer capacity.
The reader should accumulate enough bytes before decoding and throw `MALException` when the stream or buffer cannot satisfy the requested length.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.