Fix naive overflow

This commit is contained in:
世界 2022-10-18 17:52:52 +08:00
parent fc533cd38d
commit 92a92f39c5
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -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