]> Cypherpunks.ru repositories - govpn.git/commitdiff
Input transport data size check
authorSergey Matveev <stargrave@stargrave.org>
Wed, 6 Jan 2016 15:22:57 +0000 (18:22 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 6 Jan 2016 15:22:57 +0000 (18:22 +0300)
Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
src/govpn/peer.go
src/govpn/peer_test.go

index a8db9459569e8d7376fc92112652c011e24859f6..5ea245bbd44a02aa196c66801b3bd22b4c3f19f3 100644 (file)
@@ -300,6 +300,9 @@ func (p *Peer) PktProcess(data []byte, tap io.Writer, reorderable bool) bool {
        if len(data) < MinPktLength {
                return false
        }
+       if !p.Encless && len(data) > len(p.bufR)-S20BS {
+               return false
+       }
        var out []byte
        p.BusyR.Lock()
        if p.Encless {
index c0200e374d2d7ca6868bcfd7bdfeb108252b9140..c39106029249172d91f3354b8e2bbf55df64d7ab 100644 (file)
@@ -129,3 +129,9 @@ func BenchmarkDec(b *testing.B) {
                }
        }
 }
+
+func TestTransportBigger(t *testing.T) {
+       tmp := make([]byte, MTUMax*4)
+       Rand.Read(tmp)
+       peer.PktProcess(tmp, Dummy{nil}, true)
+}