mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-16 17:42:21 +08:00
Fix naive overflow
This commit is contained in:
parent
fc533cd38d
commit
92a92f39c5
|
@ -252,7 +252,14 @@ func (c *naiveH1Conn) read(p []byte) (n int, err error) {
|
|||
c.paddingRemaining = 0
|
||||
}
|
||||
if c.readPadding < kFirstPaddings {
|
||||
paddingHdr := p[:3]
|
||||
var paddingHdr []byte
|
||||
if len(p) >= 3 {
|
||||
paddingHdr = p[:3]
|
||||
} else {
|
||||
_paddingHdr := make([]byte, 3)
|
||||
defer common.KeepAlive(_paddingHdr)
|
||||
paddingHdr = common.Dup(_paddingHdr)
|
||||
}
|
||||
_, err = io.ReadFull(c.Conn, paddingHdr)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -424,7 +431,14 @@ func (c *naiveH2Conn) read(p []byte) (n int, err error) {
|
|||
c.paddingRemaining = 0
|
||||
}
|
||||
if c.readPadding < kFirstPaddings {
|
||||
paddingHdr := p[:3]
|
||||
var paddingHdr []byte
|
||||
if len(p) >= 3 {
|
||||
paddingHdr = p[:3]
|
||||
} else {
|
||||
_paddingHdr := make([]byte, 3)
|
||||
defer common.KeepAlive(_paddingHdr)
|
||||
paddingHdr = common.Dup(_paddingHdr)
|
||||
}
|
||||
_, err = io.ReadFull(c.reader, paddingHdr)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue
Block a user