1 Star 0 Fork 48

庞庆/systemd_1

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0202-journal-remote-do-not-request-Content-Length-if-Tran.patch 3.53 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:59 . import systemd-239-29.el8.src.rpm
From f551c05e4799386508e10f0f007251e426493a67 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Mon, 11 Mar 2019 12:27:18 +0900
Subject: [PATCH] journal-remote: do not request Content-Length if
Transfer-Encoding is chunked
This fixes a bug introduced by 7fdb237f5473cb8fc2129e57e8a0039526dcb4fd.
Closes #11571.
(cherry picked from commit a289dfd69b3ff4bccdde93e84b67c947bafa27e1)
Resolves: #1708849
---
src/journal-remote/journal-remote-main.c | 41 ++++++++++++++++--------
1 file changed, 27 insertions(+), 14 deletions(-)
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index 5b0bbba310..47fe9d7433 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -254,6 +254,7 @@ static int request_handler(
const char *header;
int r, code, fd;
_cleanup_free_ char *hostname = NULL;
+ bool chunked = false;
size_t len;
assert(connection);
@@ -279,21 +280,33 @@ static int request_handler(
return mhd_respond(connection, MHD_HTTP_UNSUPPORTED_MEDIA_TYPE,
"Content-Type: application/vnd.fdo.journal is required.");
+ header = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, "Transfer-Encoding");
+ if (header) {
+ if (!strcaseeq(header, "chunked"))
+ return mhd_respondf(connection, 0, MHD_HTTP_BAD_REQUEST,
+ "Unsupported Transfer-Encoding type: %s", header);
+
+ chunked = true;
+ }
+
header = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, "Content-Length");
- if (!header)
- return mhd_respond(connection, MHD_HTTP_LENGTH_REQUIRED,
- "Content-Length header is required.");
- r = safe_atozu(header, &len);
- if (r < 0)
- return mhd_respondf(connection, r, MHD_HTTP_LENGTH_REQUIRED,
- "Content-Length: %s cannot be parsed: %m", header);
-
- if (len > ENTRY_SIZE_MAX)
- /* When serialized, an entry of maximum size might be slightly larger,
- * so this does not correspond exactly to the limit in journald. Oh well.
- */
- return mhd_respondf(connection, 0, MHD_HTTP_PAYLOAD_TOO_LARGE,
- "Payload larger than maximum size of %u bytes", ENTRY_SIZE_MAX);
+ if (header) {
+ if (chunked)
+ return mhd_respond(connection, MHD_HTTP_BAD_REQUEST,
+ "Content-Length must not specified when Transfer-Encoding type is 'chuncked'");
+
+ r = safe_atozu(header, &len);
+ if (r < 0)
+ return mhd_respondf(connection, r, MHD_HTTP_LENGTH_REQUIRED,
+ "Content-Length: %s cannot be parsed: %m", header);
+
+ if (len > ENTRY_SIZE_MAX)
+ /* When serialized, an entry of maximum size might be slightly larger,
+ * so this does not correspond exactly to the limit in journald. Oh well.
+ */
+ return mhd_respondf(connection, 0, MHD_HTTP_PAYLOAD_TOO_LARGE,
+ "Payload larger than maximum size of %u bytes", ENTRY_SIZE_MAX);
+ }
{
const union MHD_ConnectionInfo *ci;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pang-qing/systemd_1.git
git@gitee.com:pang-qing/systemd_1.git
pang-qing
systemd_1
systemd_1
a8

搜索帮助