Skip to content

Commit 6ba1f26

Browse files
committed
Fix zlib compression
1 parent 416f8a0 commit 6ba1f26

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/java/net/schmizz/sshj/transport/compression/ZlibCompression.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import net.schmizz.sshj.common.Buffer;
2323
import net.schmizz.sshj.common.DisconnectReason;
2424
import net.schmizz.sshj.transport.TransportException;
25-
import net.schmizz.sshj.transport.compression.Compression;
2625

2726
public class ZlibCompression implements Compression {
2827

@@ -71,10 +70,14 @@ public boolean isDelayed() {
7170
public void compress(Buffer buffer) {
7271
deflater.setInput(buffer.array(), buffer.rpos(), buffer.available());
7372
buffer.wpos(buffer.rpos());
74-
do {
73+
while (true) {
7574
final int len = deflater.deflate(tempBuf, 0, BUF_SIZE, Deflater.SYNC_FLUSH);
76-
buffer.putRawBytes(tempBuf, 0, len);
77-
} while (!deflater.needsInput());
75+
if(len > 0) {
76+
buffer.putRawBytes(tempBuf, 0, len);
77+
} else {
78+
return;
79+
}
80+
}
7881
}
7982

8083
@Override

0 commit comments

Comments
 (0)