SUGGESTED FIX
> The problem could be fixed in sun\net\ftp\FtpClient.java
> in method openDataConnection by setting myAddress=serverSocket.getInetAddress()
> (rather than InetAddress.getLocalHost()) to get the ip address of the original
> connection.
>
> serverSocket is the actual socket we used to connect to the ftp client,
> so does have the right address to tell the ftp host to connect back to.
>
> The code change has been tested and it does work.
>
> FtpClient.java:
>
> protected Socket openDataConnection(String cmd) throws IOException {
> ServerSocket portSocket;
> String portCmd;
> // InetAddress myAddress = InetAddress.getLocalHost(); /*xxx.7813*/
> InetAddress myAddress = serverSocket.getInetAddress(); /*xxx.7813*/
> byte addr[] = myAddress.getAddress();
> int shift;
> IOException e;
>
> // portSocket = new ServerSocket(0, 1); /*xxx.7813*/
> portSocket = new ServerSocket(0, 1, myAddress); /*xxx.7813*/
> portCmd = "PORT ";
>
> The other line isn't strictly needed, but if we are telling the ftp host to
> connect back to a specific address of ours, is there any point on listening
> on all the local addresss? Shouldn't we just listen on the one we are
> interested in. This may be better for security reasons as well.
mick.fleming@Ireland 1998-11-30
|