13 Star 0 Fork 23

src-openEuler/etcd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0007-fix-CVE-2022-34038.patch 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
TD北岸花园 提交于 2024-04-19 11:22 . fix CVE-2022-34038
From 10fdd367a2095806b025c1c54d30886369b3d586 Mon Sep 17 00:00:00 2001
From: bwzhang <zhangbowei@kylinos.cn>
Date: Fri, 19 Apr 2024 11:11:10 +0800
Subject: [PATCH] fix CVE-2022-34038
---
pkg/ioutil/pagewriter.go | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/pkg/ioutil/pagewriter.go b/pkg/ioutil/pagewriter.go
index cf9a8dc..4daaa9d 100644
--- a/pkg/ioutil/pagewriter.go
+++ b/pkg/ioutil/pagewriter.go
@@ -16,6 +16,7 @@ package ioutil
import (
"io"
+ "fmt"
)
var defaultBufferBytes = 128 * 1024
@@ -38,9 +39,18 @@ type PageWriter struct {
bufWatermarkBytes int
}
+// Assert will panic with a given formatted message if the given condition is false.
+func Assert(condition bool, msg string, v int) {
+ if !condition {
+ panic(fmt.Sprintf("assertion failed: "+msg, v))
+ }
+}
+
// NewPageWriter creates a new PageWriter. pageBytes is the number of bytes
// to write per page. pageOffset is the starting offset of io.Writer.
func NewPageWriter(w io.Writer, pageBytes, pageOffset int) *PageWriter {
+ // If pageBytes is 0 or less, it will trigger a panic directly
+ Assert(pageBytes > 0, "pageBytes %d is an invalid value, it must be greater than 0", pageBytes)
return &PageWriter{
w: w,
pageOffset: pageOffset,
--
2.20.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/etcd.git
git@gitee.com:src-openeuler/etcd.git
src-openeuler
etcd
etcd
master

搜索帮助