mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 04:07:35 +03:00
use a single bytes.Reader for frame parsing (#3536)
This commit is contained in:
parent
93e1d031b9
commit
dfd35cb071
8 changed files with 104 additions and 61 deletions
|
@ -1,7 +1,6 @@
|
|||
package frames
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
|
@ -37,19 +36,19 @@ func Fuzz(data []byte) int {
|
|||
parser := wire.NewFrameParser(true, version)
|
||||
parser.SetAckDelayExponent(protocol.DefaultAckDelayExponent)
|
||||
|
||||
r := bytes.NewReader(data)
|
||||
initialLen := r.Len()
|
||||
initialLen := len(data)
|
||||
|
||||
var frames []wire.Frame
|
||||
|
||||
for r.Len() > 0 {
|
||||
f, err := parser.ParseNext(r, encLevel)
|
||||
for len(data) > 0 {
|
||||
l, f, err := parser.ParseNext(data, encLevel)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
data = data[l:]
|
||||
frames = append(frames, f)
|
||||
}
|
||||
parsedLen := initialLen - r.Len()
|
||||
parsedLen := initialLen - len(data)
|
||||
|
||||
if len(frames) == 0 {
|
||||
return 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue