Skip to content

Commit

Permalink
Added check into BufferedChannel's read to avoid endless loop if dest…
Browse files Browse the repository at this point in the history
… buffer's remaining capacity is not as much as length
  • Loading branch information
StefanoBelli committed Sep 18, 2024
1 parent 222345f commit f2df336
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ public long forceWrite(boolean forceMetadata) throws IOException {

@Override
public synchronized int read(ByteBuf dest, long pos, int length) throws IOException {
if(dest.writableBytes() < length) {
throw new IllegalArgumentException("dest buffer remaining capacity is not enough" +
"(must be at least as \"length\"=" + length +")");
}

long prevPos = pos;
while (length > 0) {
// check if it is in the write buffer
Expand Down

0 comments on commit f2df336

Please sign in to comment.