esa / esa/mo-services-java

Binary decoder returns incorrect data after short stream reads

Aperta
#56 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
17
Fork
11
Merge medio
15m
PR unite (30g)
1

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Iniziare da BaseBinaryInputReader.checkBuffer() e riprodurre il problema con l’esempio fornito di FixedBinaryDecoder e ByteArrayInputStream frammentato. Tracciare directGetBytes() per l’input costituito da un array di byte e la gestione di MALException. Il lavoro è completato quando le letture frammentate accumulano i byte richiesti, gli stream o i buffer insufficienti generano MALException e interi, stringhe e blocchi di byte non contengono più dati errati o riempiti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
76/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.