1 Star 0 Fork 21

lishiyangasdf / squid

forked from src-openEuler / squid 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2020-8449_CVE-2020-8450.patch 2.51 KB
一键复制 编辑 原始数据 按行查看 历史
From f9fb256a80f966d7f7af7d2e04438366c74258c7 Mon Sep 17 00:00:00 2001
From: Guido Vranken <guidovranken@users.noreply.github.com>
Date: Thu, 12 Dec 2019 03:27:40 +0000
Subject: [PATCH] Fix request URL generation in reverse proxy configurations
(#519)
---
src/client_side.cc | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/src/client_side.cc b/src/client_side.cc
index 538bd5e..671f6c6 100644
--- a/src/client_side.cc
+++ b/src/client_side.cc
@@ -1141,26 +1141,22 @@ prepareAcceleratedURL(ConnStateData * conn, const Http1::RequestParserPointer &h
if (vport < 0)
vport = conn->clientConnection->local.port();
- char *host = NULL;
- if (vhost && (host = hp->getHostHeaderField())) {
+ char *receivedHost = nullptr;
+ if (vhost && (receivedHost = hp->getHostHeaderField())) {
+ SBuf host(receivedHost);
debugs(33, 5, "ACCEL VHOST REWRITE: vhost=" << host << " + vport=" << vport);
- char thost[256];
if (vport > 0) {
- thost[0] = '\0';
- char *t = NULL;
- if (host[strlen(host) - 1] != ']' && (t = strrchr(host,':')) != nullptr) {
- strncpy(thost, host, (t-host));
- snprintf(thost+(t-host), sizeof(thost)-(t-host), ":%d", vport);
- host = thost;
- } else if (!t) {
- snprintf(thost, sizeof(thost), "%s:%d",host, vport);
- host = thost;
+ // remove existing :port (if any), cope with IPv6+ without port
+ const auto lastColonPos = host.rfind(':');
+ if (lastColonPos != SBuf::npos && *host.rbegin() != ']') {
+ host.chop(0, lastColonPos); // truncate until the last colon
}
+ host.appendf(":%d", vport);
} // else nothing to alter port-wise.
const SBuf &scheme = AnyP::UriScheme(conn->transferProtocol.protocol).image();
- const int url_sz = scheme.length() + strlen(host) + url.length() + 32;
+ const auto url_sz = scheme.length() + host.length() + url.length() + 32;
char *uri = static_cast<char *>(xcalloc(url_sz, 1));
- snprintf(uri, url_sz, SQUIDSBUFPH "://%s" SQUIDSBUFPH, SQUIDSBUFPRINT(scheme), host, SQUIDSBUFPRINT(url));
+ snprintf(uri, url_sz, SQUIDSBUFPH "://" SQUIDSBUFPH SQUIDSBUFPH, SQUIDSBUFPRINT(scheme), SQUIDSBUFPRINT(host), SQUIDSBUFPRINT(url));
debugs(33, 5, "ACCEL VHOST REWRITE: " << uri);
return uri;
} else if (conn->port->defaultsite /* && !vhost */) {
--
1.8.3.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lishiyangasdf/squid.git
git@gitee.com:lishiyangasdf/squid.git
lishiyangasdf
squid
squid
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891