mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-11-23 22:06:12 +03:00
Fix crash when serving non-canonalized endpoints
This commit is contained in:
parent
e12009df79
commit
c9a374fbde
@ -275,7 +275,7 @@ int InitSocketHandleForWebSocketRequest(
|
|||||||
std::move(callback), proxy_auth_callback);
|
std::move(callback), proxy_auth_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InitSocketHandleForRawConnect2(const HostPortPair& endpoint,
|
int InitSocketHandleForRawConnect2(url::SchemeHostPort endpoint,
|
||||||
HttpNetworkSession* session,
|
HttpNetworkSession* session,
|
||||||
int request_load_flags,
|
int request_load_flags,
|
||||||
RequestPriority request_priority,
|
RequestPriority request_priority,
|
||||||
@ -289,9 +289,8 @@ int InitSocketHandleForRawConnect2(const HostPortPair& endpoint,
|
|||||||
CompletionOnceCallback callback) {
|
CompletionOnceCallback callback) {
|
||||||
DCHECK(socket_handle);
|
DCHECK(socket_handle);
|
||||||
return InitSocketPoolHelper(
|
return InitSocketPoolHelper(
|
||||||
{"http", endpoint.HostForURL(), endpoint.port()}, request_load_flags,
|
std::move(endpoint), request_load_flags, request_priority, session,
|
||||||
request_priority, session, proxy_info, ssl_config_for_origin,
|
proxy_info, ssl_config_for_origin, ssl_config_for_proxy,
|
||||||
ssl_config_for_proxy,
|
|
||||||
/*is_for_websockets=*/true, privacy_mode,
|
/*is_for_websockets=*/true, privacy_mode,
|
||||||
std::move(network_isolation_key), SecureDnsPolicy::kDisable, SocketTag(),
|
std::move(network_isolation_key), SecureDnsPolicy::kDisable, SocketTag(),
|
||||||
net_log, 0, socket_handle, HttpNetworkSession::NORMAL_SOCKET_POOL,
|
net_log, 0, socket_handle, HttpNetworkSession::NORMAL_SOCKET_POOL,
|
||||||
|
@ -126,7 +126,7 @@ int InitSocketHandleForWebSocketRequest(
|
|||||||
const ClientSocketPool::ProxyAuthCallback& proxy_auth_callback);
|
const ClientSocketPool::ProxyAuthCallback& proxy_auth_callback);
|
||||||
|
|
||||||
NET_EXPORT int InitSocketHandleForRawConnect2(
|
NET_EXPORT int InitSocketHandleForRawConnect2(
|
||||||
const HostPortPair& endpoint,
|
url::SchemeHostPort endpoint,
|
||||||
HttpNetworkSession* session,
|
HttpNetworkSession* session,
|
||||||
int request_load_flags,
|
int request_load_flags,
|
||||||
RequestPriority request_priority,
|
RequestPriority request_priority,
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "net/base/load_flags.h"
|
#include "net/base/load_flags.h"
|
||||||
#include "net/base/net_errors.h"
|
#include "net/base/net_errors.h"
|
||||||
#include "net/base/privacy_mode.h"
|
#include "net/base/privacy_mode.h"
|
||||||
|
#include "net/base/url_util.h"
|
||||||
#include "net/proxy_resolution/proxy_info.h"
|
#include "net/proxy_resolution/proxy_info.h"
|
||||||
#include "net/socket/client_socket_handle.h"
|
#include "net/socket/client_socket_handle.h"
|
||||||
#include "net/socket/client_socket_pool_manager.h"
|
#include "net/socket/client_socket_pool_manager.h"
|
||||||
@ -27,6 +28,7 @@
|
|||||||
#include "net/tools/naive/http_proxy_socket.h"
|
#include "net/tools/naive/http_proxy_socket.h"
|
||||||
#include "net/tools/naive/redirect_resolver.h"
|
#include "net/tools/naive/redirect_resolver.h"
|
||||||
#include "net/tools/naive/socks5_server_socket.h"
|
#include "net/tools/naive/socks5_server_socket.h"
|
||||||
|
#include "url/scheme_host_port.h"
|
||||||
|
|
||||||
#if defined(OS_LINUX)
|
#if defined(OS_LINUX)
|
||||||
#include <linux/netfilter_ipv4.h>
|
#include <linux/netfilter_ipv4.h>
|
||||||
@ -243,8 +245,12 @@ int NaiveConnection::DoConnectServer() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (origin.IsEmpty()) {
|
url::CanonHostInfo host_info;
|
||||||
LOG(ERROR) << "Connection " << id_ << " to invalid origin";
|
url::SchemeHostPort endpoint(
|
||||||
|
"http", CanonicalizeHost(origin.host(), &host_info), origin.port(),
|
||||||
|
url::SchemeHostPort::ALREADY_CANONICALIZED);
|
||||||
|
if (!endpoint.IsValid()) {
|
||||||
|
LOG(ERROR) << "Connection " << id_ << " to invalid origin " << origin.ToString();
|
||||||
return ERR_ADDRESS_INVALID;
|
return ERR_ADDRESS_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +258,7 @@ int NaiveConnection::DoConnectServer() {
|
|||||||
|
|
||||||
// Ignores socket limit set by socket pool for this type of socket.
|
// Ignores socket limit set by socket pool for this type of socket.
|
||||||
return InitSocketHandleForRawConnect2(
|
return InitSocketHandleForRawConnect2(
|
||||||
origin, session_, LOAD_IGNORE_LIMITS, MAXIMUM_PRIORITY, proxy_info_,
|
std::move(endpoint), session_, LOAD_IGNORE_LIMITS, MAXIMUM_PRIORITY, proxy_info_,
|
||||||
server_ssl_config_, proxy_ssl_config_, PRIVACY_MODE_DISABLED,
|
server_ssl_config_, proxy_ssl_config_, PRIVACY_MODE_DISABLED,
|
||||||
network_isolation_key_, net_log_, server_socket_handle_.get(),
|
network_isolation_key_, net_log_, server_socket_handle_.get(),
|
||||||
io_callback_);
|
io_callback_);
|
||||||
|
Loading…
Reference in New Issue
Block a user