fully read port in socks connection

incoming direct connections in receive mode wouldn’t clear the entire
destination from the input stream; thus adding a leading 0x00 to the file

fixes #3557
This commit is contained in:
Daniel Gultsch 2019-10-03 20:47:28 +02:00
parent 3d332f6f35
commit 6776603b90
2 changed files with 4 additions and 3 deletions

View File

@ -52,7 +52,7 @@ public class SocksSocketFactory {
return false; return false;
} }
public static Socket createSocket(InetSocketAddress address, String destination, int port) throws IOException { private static Socket createSocket(InetSocketAddress address, String destination, int port) throws IOException {
Socket socket = new Socket(); Socket socket = new Socket();
try { try {
socket.connect(address, Config.CONNECT_TIMEOUT * 1000); socket.connect(address, Config.CONNECT_TIMEOUT * 1000);

View File

@ -120,7 +120,8 @@ public class JingleSocks5Transport extends JingleTransport {
int destinationCount = inputStream.read(); int destinationCount = inputStream.read();
final byte[] destination = new byte[destinationCount]; final byte[] destination = new byte[destinationCount];
inputStream.read(destination); inputStream.read(destination);
final int port = inputStream.read(); final byte[] port = new byte[2];
inputStream.read(port);
final String receivedDestination = new String(destination); final String receivedDestination = new String(destination);
final ByteBuffer response = ByteBuffer.allocate(7 + destination.length); final ByteBuffer response = ByteBuffer.allocate(7 + destination.length);
final byte[] responseHeader; final byte[] responseHeader;
@ -136,7 +137,7 @@ public class JingleSocks5Transport extends JingleTransport {
response.put(responseHeader); response.put(responseHeader);
response.put((byte) destination.length); response.put((byte) destination.length);
response.put(destination); response.put(destination);
response.putShort((short) port); response.put(port);
outputStream.write(response.array()); outputStream.write(response.array());
outputStream.flush(); outputStream.flush();
if (success) { if (success) {