This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git

commit 19f5d82b4635abdd24b7ed2bffd6e6a1a90d661d
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Feb 15 16:21:36 2025 -0500

    Avoid multiple possible NullPointerException in
    SocketClient.verifyRemote(Socket)
---
 src/changes/changes.xml                                | 1 +
 src/main/java/org/apache/commons/net/SocketClient.java | 8 +-------
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a4d4468d..d15ae947 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -83,6 +83,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate 
PrintCommandListeners.PrintCommandListeners().</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate 
NtpUtils.NtpUtils().</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate 
FTPFileFilters.FTPFileFilters().</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Avoid multiple 
possible NullPointerException in SocketClient.verifyRemote(Socket).</action>
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="Gary 
Gregory">org.apache.commons.net.nntp.Article#getChild().</action>
       <action type="add" dev="ggregory" due-to="Gary 
Gregory">org.apache.commons.net.nntp.Article#getNext().</action>
diff --git a/src/main/java/org/apache/commons/net/SocketClient.java 
b/src/main/java/org/apache/commons/net/SocketClient.java
index a2d340d3..6348e88a 100644
--- a/src/main/java/org/apache/commons/net/SocketClient.java
+++ b/src/main/java/org/apache/commons/net/SocketClient.java
@@ -767,13 +767,7 @@ public abstract class SocketClient {
      * @return True if the remote hosts are the same, false if not.
      */
     public boolean verifyRemote(final Socket socket) {
-        final InetAddress host1;
-        final InetAddress host2;
-
-        host1 = socket.getInetAddress();
-        host2 = getRemoteAddress();
-
-        return host1.equals(host2);
+        return socket != null && Objects.equals(socket.getInetAddress(), 
getRemoteAddress());
     }
 
     /*

Reply via email to