mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-25 01:51:29 +00:00
Fix vision padding overflow
This commit is contained in:
parent
0558b3fc5c
commit
46040a71c3
|
@ -286,14 +286,23 @@ func (c *VisionConn) padding(buffer *buf.Buffer, command byte) *buf.Buffer {
|
||||||
l, _ := rand.Int(rand.Reader, big.NewInt(256))
|
l, _ := rand.Int(rand.Reader, big.NewInt(256))
|
||||||
paddingLen = int(l.Int64())
|
paddingLen = int(l.Int64())
|
||||||
}
|
}
|
||||||
newBuffer := buf.New()
|
var bufferLen int
|
||||||
if c.writeUUID {
|
if c.writeUUID {
|
||||||
newBuffer.Write(c.userUUID[:])
|
bufferLen += 16
|
||||||
|
}
|
||||||
|
bufferLen += 5
|
||||||
|
if buffer != nil {
|
||||||
|
bufferLen += buffer.Len()
|
||||||
|
}
|
||||||
|
bufferLen += paddingLen
|
||||||
|
newBuffer := buf.NewSize(bufferLen)
|
||||||
|
if c.writeUUID {
|
||||||
|
common.Must1(newBuffer.Write(c.userUUID[:]))
|
||||||
c.writeUUID = false
|
c.writeUUID = false
|
||||||
}
|
}
|
||||||
newBuffer.Write([]byte{command, byte(contentLen >> 8), byte(contentLen), byte(paddingLen >> 8), byte(paddingLen)})
|
common.Must1(newBuffer.Write([]byte{command, byte(contentLen >> 8), byte(contentLen), byte(paddingLen >> 8), byte(paddingLen)}))
|
||||||
if buffer != nil {
|
if buffer != nil {
|
||||||
newBuffer.Write(buffer.Bytes())
|
common.Must1(newBuffer.Write(buffer.Bytes()))
|
||||||
buffer.Release()
|
buffer.Release()
|
||||||
}
|
}
|
||||||
newBuffer.Extend(paddingLen)
|
newBuffer.Extend(paddingLen)
|
||||||
|
|
Loading…
Reference in a new issue