From 5b2e4e50d0bdd76fc1239cae86151c72198f1131 Mon Sep 17 00:00:00 2001 From: Javid Khan Date: Sun, 4 Oct 2026 19:09:58 +0530 Subject: [PATCH] enable remote verification by default in RExecClient The class documents that error-stream peer verification is enabled by default, and FTPClient initialises the same flag to true, but the field was left uninitialised so it defaulted to false and the check in createErrorStream was skipped. --- src/main/java/org/apache/commons/net/bsd/RExecClient.java | 2 +- .../java/org/apache/commons/net/bsd/RCommandClientTest.java | 6 ++++++ .../java/org/apache/commons/net/bsd/RExecClientTest.java | 6 ++++++ .../java/org/apache/commons/net/bsd/RLoginClientTest.java | 6 ++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/net/bsd/RExecClient.java b/src/main/java/org/apache/commons/net/bsd/RExecClient.java index aaf4d5406..63961dde5 100644 --- a/src/main/java/org/apache/commons/net/bsd/RExecClient.java +++ b/src/main/java/org/apache/commons/net/bsd/RExecClient.java @@ -65,7 +65,7 @@ public class RExecClient extends SocketClient { */ public static final int DEFAULT_PORT = 512; - private boolean remoteVerificationEnabled; + private boolean remoteVerificationEnabled = true; /** * If a separate error stream is requested, {@code _errorStream_} will point to an InputStream from which the standard error of the remote process can diff --git a/src/test/java/org/apache/commons/net/bsd/RCommandClientTest.java b/src/test/java/org/apache/commons/net/bsd/RCommandClientTest.java index 00640fbbb..15b1c7055 100644 --- a/src/test/java/org/apache/commons/net/bsd/RCommandClientTest.java +++ b/src/test/java/org/apache/commons/net/bsd/RCommandClientTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.io.InputStream; @@ -52,4 +53,9 @@ void testGetInputStream() throws IOException { } } + @Test + void testRemoteVerificationEnabledByDefault() { + assertTrue(newClient().isRemoteVerificationEnabled()); + } + } diff --git a/src/test/java/org/apache/commons/net/bsd/RExecClientTest.java b/src/test/java/org/apache/commons/net/bsd/RExecClientTest.java index cac9781bc..d1dc70e24 100644 --- a/src/test/java/org/apache/commons/net/bsd/RExecClientTest.java +++ b/src/test/java/org/apache/commons/net/bsd/RExecClientTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.io.InputStream; @@ -67,4 +68,9 @@ void testGetOutputStream() throws IOException { } } + @Test + void testRemoteVerificationEnabledByDefault() { + assertTrue(newClient().isRemoteVerificationEnabled()); + } + } diff --git a/src/test/java/org/apache/commons/net/bsd/RLoginClientTest.java b/src/test/java/org/apache/commons/net/bsd/RLoginClientTest.java index e0212a45d..62eb7c122 100644 --- a/src/test/java/org/apache/commons/net/bsd/RLoginClientTest.java +++ b/src/test/java/org/apache/commons/net/bsd/RLoginClientTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.io.InputStream; @@ -52,4 +53,9 @@ void testGetInputStream() throws IOException { } } + @Test + void testRemoteVerificationEnabledByDefault() { + assertTrue(newClient().isRemoteVerificationEnabled()); + } + }