You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2020/06/19 23:08:10 UTC
[commons-net] branch master updated: [NET-663] Retrieve socket host
before closing if remote verification fails
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git
The following commit(s) were added to refs/heads/master by this push:
new 3c01bfa [NET-663] Retrieve socket host before closing if remote verification fails
new d28e5f0 Merge pull request #50 from mshenfield/NET-663-FTP-NullPointerException
3c01bfa is described below
commit 3c01bfaa968514749d54218f910563ac19d970cf
Author: Max Shenfield <ms...@google.com>
AuthorDate: Sun Dec 23 03:46:22 2018 +0000
[NET-663] Retrieve socket host before closing if remote verification fails
This retrieves the socket host before closing the socket
when remote verification fails. In NET-663, socket.getInetAddress()
returned a null after the socket was closed, causing a
NullPointerException instead of the more helpful error message intended.
---
src/main/java/org/apache/commons/net/ftp/FTPClient.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPClient.java b/src/main/java/org/apache/commons/net/ftp/FTPClient.java
index 9b9c260..7a6944f 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPClient.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPClient.java
@@ -937,10 +937,13 @@ implements Configurable
if (__remoteVerificationEnabled && !verifyRemote(socket))
{
+ // Grab the host before we close the socket to avoid NET-663
+ InetAddress socketHost = socket.getInetAddress();
+
socket.close();
throw new IOException(
- "Host attempting data connection " + socket.getInetAddress().getHostAddress() +
+ "Host attempting data connection " + socketHost.getHostAddress() +
" is not same as server " + getRemoteAddress().getHostAddress());
}