From 41e055953391700001da179fc251d2a304fa4157 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 26 Oct 2019 16:52:31 +0200 Subject: fully read port in socks connection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit incoming direct connections in receive mode wouldn’t clear the entire destination from the input stream; thus adding a leading 0x00 to the file --- src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java | 2 +- .../java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main/java/de/pixart/messenger') diff --git a/src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java b/src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java index 8a251a6a0..266bb9d8c 100644 --- a/src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java +++ b/src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java @@ -50,7 +50,7 @@ public class SocksSocketFactory { 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(); try { socket.connect(address, Config.CONNECT_TIMEOUT * 1000); diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java index 1fc69ec6f..5d3cef8ae 100644 --- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java +++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleSocks5Transport.java @@ -118,7 +118,8 @@ public class JingleSocks5Transport extends JingleTransport { int destinationCount = inputStream.read(); final byte[] destination = new byte[destinationCount]; inputStream.read(destination); - final int port = inputStream.read(); + final byte[] port = new byte[2]; + inputStream.read(port); final String receivedDestination = new String(destination); final ByteBuffer response = ByteBuffer.allocate(7 + destination.length); final byte[] responseHeader; @@ -134,7 +135,7 @@ public class JingleSocks5Transport extends JingleTransport { response.put(responseHeader); response.put((byte) destination.length); response.put(destination); - response.putShort((short) port); + response.put(port); outputStream.write(response.array()); outputStream.flush(); if (success) { -- cgit v1.2.3