This is an automated email from the ASF dual-hosted git repository. twolf pushed a commit to branch dev_3.0 in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
commit 0013598b283f0a5643f05da98cea16c0c1233023 Author: Thomas Wolf <[email protected]> AuthorDate: Wed Apr 1 22:50:02 2026 +0200 CompressionZlib: fix init() An old refactoring in 2014 ignored the `type` parameter. Re-add the old logic from before and initialize only either a Deflater or an Inflater, but not both. This is marginally safer than eliminating Compression.Type instead. A Compression is not thread-safe, and two different instances must be used for reading or writing packets when compression is on. By actually enforcing the type here, we forbid re-using the same instance on both paths, and moreover, to initialize both instances correctly. (Using Compression.Type.Inflater for reading and Compression.Type.Deflater for writing.) --- .../org/apache/sshd/common/compression/CompressionZlib.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionZlib.java b/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionZlib.java index 12d5751ee..4b27d0a9f 100644 --- a/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionZlib.java +++ b/sshd-common/src/main/java/org/apache/sshd/common/compression/CompressionZlib.java @@ -60,8 +60,16 @@ public class CompressionZlib extends BaseCompression { @Override public void init(Type type, int level) { - compressor = new Deflater(level); - decompressor = new Inflater(); + switch (type) { + case Deflater: + compressor = new Deflater(level); + break; + case Inflater: + decompressor = new Inflater(); + break; + default: + throw new IllegalArgumentException("Unknown Compression.Type " + type); + } } @Override
