mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 16:41:30 +00: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
|
c.paddingRemaining = 0
|
||||||
}
|
}
|
||||||
if c.readPadding < kFirstPaddings {
|
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)
|
_, err = io.ReadFull(c.Conn, paddingHdr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -424,7 +431,14 @@ func (c *naiveH2Conn) read(p []byte) (n int, err error) {
|
||||||
c.paddingRemaining = 0
|
c.paddingRemaining = 0
|
||||||
}
|
}
|
||||||
if c.readPadding < kFirstPaddings {
|
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)
|
_, err = io.ReadFull(c.reader, paddingHdr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue