зеркало из https://github.com/mozilla/gecko-dev.git
Bug Id: 304195
Added try/catch block around the method calls within toString(). Calls such as getInetAddress(), getPort() etc does not check if the socket is closed, and when applications use toString() on a closed socket, there is an uncaught exception.
This commit is contained in:
Родитель
5307a7e218
Коммит
9c0e116e76
|
@ -434,15 +434,23 @@ public class SSLServerSocket extends java.net.ServerSocket {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the addresses and ports of this socket.
|
||||
* Returns the addresses and ports of this socket
|
||||
* or an error message if the socket is not in a valid state.
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("SSLServerSocket[addr=");
|
||||
buf.append(getInetAddress());
|
||||
buf.append(",port=0,localport=");
|
||||
buf.append(getLocalPort());
|
||||
buf.append("]");
|
||||
return buf.toString();
|
||||
|
||||
try {
|
||||
InetAddress inetAddr = getInetAddress();
|
||||
int localPort = getLocalPort();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("SSLServerSocket[addr=");
|
||||
buf.append(inetAddr);
|
||||
buf.append(",localport=");
|
||||
buf.append(localPort);
|
||||
buf.append("]");
|
||||
return buf.toString();
|
||||
} catch (Exception e) {
|
||||
return "Exception caught in toString(): " + e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -818,19 +818,30 @@ public class SSLSocket extends java.net.Socket {
|
|||
throws SocketException;
|
||||
|
||||
/**
|
||||
* Returns the addresses and ports of this socket.
|
||||
* Returns the addresses and ports of this socket
|
||||
* or an error message if the socket is not in a valid state.
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("SSLSocket[addr=");
|
||||
buf.append(getInetAddress());
|
||||
buf.append(getLocalAddress());
|
||||
buf.append(",port=");
|
||||
buf.append(getPort());
|
||||
buf.append(",localport=");
|
||||
buf.append(getLocalPort());
|
||||
buf.append("]");
|
||||
return buf.toString();
|
||||
|
||||
try {
|
||||
InetAddress inetAddr = getInetAddress();
|
||||
InetAddress localAddr = getLocalAddress();
|
||||
int port = getPort();
|
||||
int localPort = getLocalPort();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("SSLSocket[addr=");
|
||||
buf.append(inetAddr);
|
||||
buf.append(",localaddr=");
|
||||
buf.append(localAddr);
|
||||
buf.append(",port=");
|
||||
buf.append(port);
|
||||
buf.append(",localport=");
|
||||
buf.append(localPort);
|
||||
buf.append("]");
|
||||
return buf.toString();
|
||||
} catch (Exception e) {
|
||||
return "Exception caught in toString(): " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче