Skip to content

Commit 7061c5a

Browse files
committed
fix: possible data location errors in vision read
1 parent 23448ec commit 7061c5a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

transport/vless/vision/conn.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"io"
99
"net"
10+
"unsafe"
1011

1112
"github.com/metacubex/mihomo/common/buf"
1213
N "github.com/metacubex/mihomo/common/net"
@@ -51,6 +52,9 @@ func (vc *Conn) Read(b []byte) (int, error) {
5152
if vc.readProcess {
5253
buffer := buf.With(b)
5354
err := vc.ReadBuffer(buffer)
55+
if unsafe.SliceData(buffer.Bytes()) != unsafe.SliceData(b) { // buffer.Bytes() not at the beginning of b
56+
copy(b, buffer.Bytes())
57+
}
5458
return buffer.Len(), err
5559
}
5660
return vc.ExtendedReader.Read(b)

0 commit comments

Comments
 (0)