yegor256 / takes

True Object-Oriented Java Web Framework without NULLs, Static Methods, Annotations, and Mutable Objects
https://www.takes.org
MIT License
805 stars 197 forks source link

org.takes.rq.ChunkedInputStream.read(byte[], int, int) behaves wrong if len > total size #1303

Open laeubi opened 2 months ago

laeubi commented 2 months ago

In ChunkedInputStream.read(byte[], int, int) there is this code:

https://github.com/yegor256/takes/blob/20467cf2729566461ad4c7fe7123cf4ea57c51ed/src/main/java/org/takes/rq/ChunkedInputStream.java#L112

but if the next chunck is EOF, the method return -1 and therefore the method claims to have read one less byte! Instead the return value must be checked, and if it is < 1 nothing should be added (or substracted in the current case).