1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-04-10 15:55:32 -04:00

Fix: security issues & overflow potentiality (#465)

This commit is contained in:
Loyalsoldier
2020-11-28 21:56:20 +08:00
committed by GitHub
parent 0bf185e705
commit 8cb2db5321
5 changed files with 31 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/golang/protobuf/proto"
"v2ray.com/core/common/buf"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/protocol"
)
@@ -67,7 +68,12 @@ type MultiLengthPacketWriter struct {
func (w *MultiLengthPacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
defer buf.ReleaseMulti(mb)
mb2Write := make(buf.MultiBuffer, 0, len(mb)+1)
if len(mb)+1 > 64*1024*1024 {
return errors.New("value too large")
}
sliceSize := len(mb) + 1
mb2Write := make(buf.MultiBuffer, 0, sliceSize)
for _, b := range mb {
length := b.Len()
if length == 0 || length+2 > buf.Size {