mirror of
https://github.com/daeuniverse/dae.git
synced 2025-02-03 12:55:13 +07:00
fix(quicSnifferReassemble): a potential panic
This commit is contained in:
parent
92596cd01e
commit
0ad34023b9
@ -7,9 +7,10 @@ package quicutils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/daeuniverse/softwind/pool"
|
||||
"io/fs"
|
||||
"sort"
|
||||
|
||||
"github.com/daeuniverse/softwind/pool"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -85,6 +86,9 @@ func ReassembleCryptoToBytesFromPool(plaintextPayload []byte) (b []byte, err err
|
||||
if offset == nil {
|
||||
continue
|
||||
}
|
||||
if offset.UpperAppOffset+len(offset.Data) >= len(b) {
|
||||
return nil, fmt.Errorf("offset.UpperAppOffset out of bound: %v:%v/%v", offset.UpperAppOffset, offset.UpperAppOffset+len(offset.Data), len(b))
|
||||
}
|
||||
copy(b[offset.UpperAppOffset:], offset.Data)
|
||||
if offset.UpperAppOffset+len(offset.Data) > boundary {
|
||||
boundary = offset.UpperAppOffset + len(offset.Data)
|
||||
@ -97,7 +101,7 @@ func ExtractCryptoFrameOffset(remainder []byte, transportOffset int) (offset *Cr
|
||||
if len(remainder) == 0 {
|
||||
return nil, 0, fmt.Errorf("frame has no length: %w", OutOfRangeError)
|
||||
}
|
||||
frameType, nextField, err := BigEndianUvarint(remainder[:])
|
||||
frameType, nextField, err := BigEndianUvarint(remainder)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
@ -197,7 +201,7 @@ func (r *CryptoFrameRelocation) RangeFromPool(i, j int) []byte {
|
||||
// copyBytesToPool copy bytes including i and j.
|
||||
func (r *CryptoFrameRelocation) copyBytesToPool(iOuter, iInner, jOuter, jInner, size int) []byte {
|
||||
b := pool.Get(size)
|
||||
//io := r.o[iOuter]
|
||||
// io := r.o[iOuter]
|
||||
k := 0
|
||||
for {
|
||||
// Most accesses are small range accesses.
|
||||
|
8
go.mod
8
go.mod
@ -8,7 +8,7 @@ require (
|
||||
github.com/bits-and-blooms/bloom/v3 v3.5.0
|
||||
github.com/cilium/ebpf v0.11.0
|
||||
github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d
|
||||
github.com/daeuniverse/softwind v0.0.0-20230821142121-f4d871b5a8c9
|
||||
github.com/daeuniverse/softwind v0.0.0-20230825151811-81c035d41785
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/miekg/dns v1.1.55
|
||||
@ -34,9 +34,9 @@ require (
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8 // indirect
|
||||
github.com/klauspost/compress v1.16.7 // indirect
|
||||
github.com/mzz2017/quic-go v0.0.0-20230821141654-3dd2575ee6bc // indirect
|
||||
github.com/mzz2017/quic-go v0.0.0-20230825151712-911c648fd461 // indirect
|
||||
github.com/onsi/ginkgo/v2 v2.11.0 // indirect
|
||||
github.com/quic-go/qtls-go1-20 v0.3.2 // indirect
|
||||
github.com/quic-go/qtls-go1-20 v0.3.3 // indirect
|
||||
golang.org/x/mod v0.12.0 // indirect
|
||||
golang.org/x/net v0.12.0 // indirect
|
||||
golang.org/x/tools v0.11.0 // indirect
|
||||
@ -72,7 +72,7 @@ require (
|
||||
|
||||
// replace github.com/daeuniverse/softwind => ../softwind
|
||||
|
||||
// replace github.com/metacubex/quic-go => ../quic-go
|
||||
// replace github.com/mzz2017/quic-go => ../quic-go
|
||||
|
||||
//replace github.com/cilium/ebpf => /home/mzz/goProjects/ebpf
|
||||
//replace github.com/daeuniverse/dae-config-dist/go/dae_config => /home/mzz/antlrProjects/dae-config/build/go/dae_config
|
||||
|
12
go.sum
12
go.sum
@ -13,8 +13,8 @@ github.com/cilium/ebpf v0.11.0/go.mod h1:WE7CZAnqOL2RouJ4f1uyNhqr2P4CCvXFIqdRDUg
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d h1:hnC39MjR7xt5kZjrKlef7DXKFDkiX8MIcDXYC/6Jf9Q=
|
||||
github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d/go.mod h1:VGWGgv7pCP5WGyHGUyb9+nq/gW0yBm+i/GfCNATOJ1M=
|
||||
github.com/daeuniverse/softwind v0.0.0-20230821142121-f4d871b5a8c9 h1:88k/mjYFuA5294C50M3rXMqRYaqSNAnuk9hnjY/xGMM=
|
||||
github.com/daeuniverse/softwind v0.0.0-20230821142121-f4d871b5a8c9/go.mod h1:K9Au9LY2ttqfAhZXxPPnyqt4Bue1dd/Xi8WPsZEgxOk=
|
||||
github.com/daeuniverse/softwind v0.0.0-20230825151811-81c035d41785 h1:XSvglD5L9ZPkCAm0bGA6AvWeNqvzq5smHcUW5P4k+sc=
|
||||
github.com/daeuniverse/softwind v0.0.0-20230825151811-81c035d41785/go.mod h1:nHhtfBue2xXWuLcczn612HpfQc3Dy1D4J0jSAk7gKC4=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@ -91,8 +91,8 @@ github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/mzz2017/disk-bloom v1.0.1 h1:rEF9MiXd9qMW3ibRpqcerLXULoTgRlM21yqqJl1B90M=
|
||||
github.com/mzz2017/disk-bloom v1.0.1/go.mod h1:JLHETtUu44Z6iBmsqzkOtFlRvXSlKnxjwiBRDapizDI=
|
||||
github.com/mzz2017/quic-go v0.0.0-20230821141654-3dd2575ee6bc h1:2gjLlS2yBxXUGICgHSWGLS5LyRa0Lr6+w5GFiqOco/o=
|
||||
github.com/mzz2017/quic-go v0.0.0-20230821141654-3dd2575ee6bc/go.mod h1:j4yzgjc6nLseaxzQT/As8D7VRQMKASjVWXBunJGTF8Y=
|
||||
github.com/mzz2017/quic-go v0.0.0-20230825151712-911c648fd461 h1:hjKKv8lOhcM1Ohyx52ZJiQZsf+ZZ8x+kKe6lGh7hneM=
|
||||
github.com/mzz2017/quic-go v0.0.0-20230825151712-911c648fd461/go.mod h1:tWtXPktBZvMi0SzXP4QFO8SKDNsAkGEijAeiNe8QmyM=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
@ -109,8 +109,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
|
||||
github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/quic-go/qtls-go1-20 v0.3.2 h1:rRgN3WfnKbyik4dBV8A6girlJVxGand/d+jVKbQq5GI=
|
||||
github.com/quic-go/qtls-go1-20 v0.3.2/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
|
||||
github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eUIDCM=
|
||||
github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
|
||||
github.com/refraction-networking/utls v1.3.2 h1:o+AkWB57mkcoW36ET7uJ002CpBWHu0KPxi6vzxvPnv8=
|
||||
github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvjQpqP7L2vcm/9KUfm/E=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
|
Loading…
Reference in New Issue
Block a user