5 Star 0 Fork 7

src-openEuler/k3s-containerd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0002-Fix-CVE-2022-23471.patch 1.94 KB
一键复制 编辑 原始数据 按行查看 历史
TD北岸花园 提交于 2024-03-15 09:53 . fix CVE-2022-23471
From 0550bb17949c1793e0da20270d3793d0e7583b1e Mon Sep 17 00:00:00 2001
From: bwzhang <zhangbowei@kylinos.cn>
Date: Fri, 15 Mar 2024 09:33:45 +0800
Subject: [PATCH] Fix CVE-2022-23471
---
pkg/cri/streaming/remotecommand/httpstream.go | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/pkg/cri/streaming/remotecommand/httpstream.go b/pkg/cri/streaming/remotecommand/httpstream.go
index 0417a1a..9177fa7 100644
--- a/pkg/cri/streaming/remotecommand/httpstream.go
+++ b/pkg/cri/streaming/remotecommand/httpstream.go
@@ -33,6 +33,7 @@ limitations under the License.
package remotecommand
import (
+ gocontext "context"
"encoding/json"
"errors"
"fmt"
@@ -132,7 +133,7 @@ func createStreams(req *http.Request, w http.ResponseWriter, opts *Options, supp
if ctx.resizeStream != nil {
ctx.resizeChan = make(chan remotecommand.TerminalSize)
- go handleResizeEvents(ctx.resizeStream, ctx.resizeChan)
+ go handleResizeEvents(req.Context(), ctx.resizeStream, ctx.resizeChan)
}
return ctx, true
@@ -425,7 +426,7 @@ WaitForStreams:
// supportsTerminalResizing returns false because v1ProtocolHandler doesn't support it.
func (*v1ProtocolHandler) supportsTerminalResizing() bool { return false }
-func handleResizeEvents(stream io.Reader, channel chan<- remotecommand.TerminalSize) {
+func handleResizeEvents(ctx gocontext.Context, stream io.Reader, channel chan<- remotecommand.TerminalSize) {
defer runtime.HandleCrash()
defer close(channel)
@@ -435,7 +436,15 @@ func handleResizeEvents(stream io.Reader, channel chan<- remotecommand.TerminalS
if err := decoder.Decode(&size); err != nil {
break
}
- channel <- size
+
+ select {
+ case channel <- size:
+ case <-ctx.Done():
+ // To avoid leaking this routine, exit if the http request finishes. This path
+ // would generally be hit if starting the process fails and nothing is started to
+ // ingest these resize events.
+ return
+ }
}
}
--
2.20.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/k3s-containerd.git
git@gitee.com:src-openeuler/k3s-containerd.git
src-openeuler
k3s-containerd
k3s-containerd
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385