1
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
昔念
2026-02-08 12:18:23 +08:00
parent 2634e6517e
commit 8988e84a01
2 changed files with 8 additions and 1 deletions

View File

@@ -159,6 +159,13 @@ func (f Fields) Unpack(r io.Reader, val reflect.Value, options *Options) error {
}
} else {
size := length * field.Type.Resolve(options).Size()
// 添加大小限制,防止分配过大的内存
const maxSize = 1024 * 1024 // 1MB 限制,可根据需求调整
if size > maxSize {
return fmt.Errorf("buffer size too large: %d bytes, max allowed: %d", size, maxSize)
}
if size < 8 {
buf = tmp[:size]
} else {

View File

@@ -36,6 +36,6 @@ type WalkInInfo struct {
// Point: 直接给坐标xy
Point model.Pos `fieldDesc:"直接给坐标xy"`
PathLen uint32 `struc:"sizeof=Path" `
PathLen uint32 `struc:"sizeof=Path"`
Path string
}