加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2024-50305.patch 2.22 KB
一键复制 编辑 原始数据 按行查看 历史
From 5e39658f7c0bc91613468c9513ba22ede1739d7e Mon Sep 17 00:00:00 2001
From: "Alan M. Carroll" <amc@apache.org>
Date: Tue, 2 Nov 2021 11:47:09 -0500
Subject: [PATCH] Tweak MimeHdr::get_host_port_values to not run over the end
of the TextView. (#8468)
Origin: https://github.com/apache/trafficserver/commit/5e39658f7c0bc91613468c9513ba22ede1739d7e
Fix for #8461
(cherry picked from commit 055ca11c2842a64bf7df8d547515670e1a04afc1)
---
proxy/hdrs/MIME.cc | 11 +++--------
src/tscpp/util/unit_tests/test_TextView.cc | 11 +++--------
2 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/proxy/hdrs/MIME.cc b/proxy/hdrs/MIME.cc
index 45c16c386dd..0a55dd06b4d 100644
--- a/proxy/hdrs/MIME.cc
+++ b/proxy/hdrs/MIME.cc
@@ -2284,20 +2284,15 @@ MIMEHdr::get_host_port_values(const char **host_ptr, ///< Pointer to host.
if (b) {
if ('[' == *b) {
auto idx = b.find(']');
- if (idx <= b.size() && b[idx + 1] == ':') {
+ if (idx < b.size() - 1 && b[idx + 1] == ':') {
host = b.take_prefix_at(idx + 1);
port = b;
} else {
host = b;
}
} else {
- auto x = b.split_prefix_at(':');
- if (x) {
- host = x;
- port = b;
- } else {
- host = b;
- }
+ host = b.take_prefix_at(':');
+ port = b;
}
if (host) {
diff --git a/src/tscpp/util/unit_tests/test_TextView.cc b/src/tscpp/util/unit_tests/test_TextView.cc
index 8f71e0aa39d..7f365369082 100644
--- a/src/tscpp/util/unit_tests/test_TextView.cc
+++ b/src/tscpp/util/unit_tests/test_TextView.cc
@@ -275,20 +275,15 @@ TEST_CASE("TextView Affixes", "[libts][TextView]")
auto f_host = [](TextView b, TextView &host, TextView &port) -> void {
if ('[' == *b) {
auto idx = b.find(']');
- if (idx <= b.size() && b[idx + 1] == ':') {
+ if (idx < b.size() - 1 && b[idx + 1] == ':') {
host = b.take_prefix_at(idx + 1);
port = b;
} else {
host = b;
}
} else {
- auto x = b.split_prefix_at(':');
- if (x) {
- host = x;
- port = b;
- } else {
- host = b;
- }
+ host = b.take_prefix_at(':');
+ port = b;
}
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化