Skip to content

Commit

Permalink
Fix zlib compression
Browse files Browse the repository at this point in the history
  • Loading branch information
hpoettker committed Oct 11, 2023
1 parent 416f8a0 commit 6ba1f26
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import net.schmizz.sshj.common.Buffer;
import net.schmizz.sshj.common.DisconnectReason;
import net.schmizz.sshj.transport.TransportException;
import net.schmizz.sshj.transport.compression.Compression;

public class ZlibCompression implements Compression {

Expand Down Expand Up @@ -71,10 +70,14 @@ public boolean isDelayed() {
public void compress(Buffer buffer) {
deflater.setInput(buffer.array(), buffer.rpos(), buffer.available());
buffer.wpos(buffer.rpos());
do {
while (true) {
final int len = deflater.deflate(tempBuf, 0, BUF_SIZE, Deflater.SYNC_FLUSH);
buffer.putRawBytes(tempBuf, 0, len);
} while (!deflater.needsInput());
if(len > 0) {
buffer.putRawBytes(tempBuf, 0, len);
} else {
return;
}
}
}

@Override
Expand Down

0 comments on commit 6ba1f26

Please sign in to comment.