Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-663

NullPointerException when FTPClient remote verification fails

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6
    • Fix Version/s: 3.7
    • Component/s: FTP
    • Environment:

      OS: Linux

      Description

      At L934 of the FTPClient code, Apache does a check to see whether the data and control connections are at the same IP address (verifyRemote). If they differ, the data connection socket is closed and an exception is raised.  This can be disabled, but is the default behavior (__remoteVerificationEnabled = true).

      I'm connecting to the FTP via a proxy. In my setup, the L934-939 code path where verifyRemote returns false always raises a java.lang.NullPointerException. socket.getInetAddress() seems to return null after socket.close is called, leading to socket.getInetAdress().getHostAddress() to raise the java.lang.NullPointerException at L938. This obfuscates a really useful error message ("Host attempting data connection is not the same as server") with a difficult to debug NullPointerException.

      Example State:

      this.__remoteVerificationEnabled -> true
      this.getRemoteAddress().toString() -> "ftp.example.com/987.654.321.000"
      socket.getInetAddress().toString() -> "/123.456.789.000"
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mshenfield Max Shenfield
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m