You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2022/11/14 21:11:37 UTC
[httpcomponents-core] 02/03: I/O reactor to validate remote endpoint address at the last moment immediately before connect
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch socks5
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
commit c9f1fa54cf0f3d830e4976129a26dec4a35ac875
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Mon Nov 14 14:47:33 2022 +0100
I/O reactor to validate remote endpoint address at the last moment immediately before connect
---
.../main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
index 0d4362079..6a465321f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
@@ -314,12 +314,10 @@ class SingleCoreIOReactor extends AbstractSingleCoreIOReactor implements Connect
}
private void processConnectionRequest(final SocketChannel socketChannel, final IOSessionRequest sessionRequest) throws IOException {
- validateAddress(sessionRequest.localAddress);
- validateAddress(sessionRequest.remoteAddress);
-
socketChannel.configureBlocking(false);
prepareSocket(socketChannel.socket());
+ validateAddress(sessionRequest.localAddress);
if (sessionRequest.localAddress != null) {
final Socket sock = socketChannel.socket();
sock.setReuseAddress(this.reactorConfig.isSoReuseAddress());
@@ -342,6 +340,7 @@ class SingleCoreIOReactor extends AbstractSingleCoreIOReactor implements Connect
// Run this under a doPrivileged to support lib users that run under a SecurityManager this allows granting connect permissions
// only to this library
+ validateAddress(targetAddress);
final boolean connected;
try {
connected = AccessController.doPrivileged(
@@ -353,7 +352,6 @@ class SingleCoreIOReactor extends AbstractSingleCoreIOReactor implements Connect
throw (IOException) e.getCause();
}
-
final SelectionKey key = socketChannel.register(this.selector, SelectionKey.OP_CONNECT | SelectionKey.OP_READ);
final InternalChannel channel = new InternalConnectChannel(key, socketChannel, sessionRequest, (k, sc, namedEndpoint, attachment) -> {
final IOSession ioSession = new IOSessionImpl("c", k, sc);