Binary decoder returns incorrect data after short stream reads
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
Research direction
Start in BaseBinaryInputReader.checkBuffer() and reproduce the issue with the provided FixedBinaryDecoder and fragmented ByteArrayInputStream example. Trace directGetBytes() for byte-array input and the handling of MALException. Done means fragmented reads accumulate the requested bytes, insufficient streams or buffers throw MALException, and integers, strings, and byte blocks no longer contain incorrect or padded data.
Written by the indexing model from the issue text.
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.
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.
- Dominant language
- Java
- Stars
- 18
- Forks
- 11
- Avg merge
- 15m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from esa/mo-services-java
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
esa/mo-services-java#37 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
esa/mo-services-java#1 ·
All issues in esa/mo-services-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100