]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/govpn/peer.go
Make SliceZero function public
[govpn.git] / src / govpn / peer.go
index 091801850f5f87478c19a2e51010702f77dc93e1..586444438c6eec127cba39333a2210b8ece91b9f 100644 (file)
@@ -1,6 +1,6 @@
 /*
 GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2015 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -127,11 +127,11 @@ func (p *Peer) String() string {
 func (p *Peer) Zero() {
        p.BusyT.Lock()
        p.BusyR.Lock()
-       sliceZero(p.Key[:])
-       sliceZero(p.bufR)
-       sliceZero(p.bufT)
-       sliceZero(p.keyAuthR[:])
-       sliceZero(p.keyAuthT[:])
+       SliceZero(p.Key[:])
+       SliceZero(p.bufR)
+       SliceZero(p.bufT)
+       SliceZero(p.keyAuthR[:])
+       SliceZero(p.keyAuthT[:])
        p.BusyT.Unlock()
        p.BusyR.Unlock()
 }
@@ -260,6 +260,9 @@ func (p *Peer) EthProcess(data []byte) {
 }
 
 func (p *Peer) PktProcess(data []byte, tap io.Writer, reorderable bool) bool {
+       if len(data) < MinPktLength {
+               return false
+       }
        p.BusyR.Lock()
        for i := 0; i < SSize; i++ {
                p.bufR[i] = byte(0)
@@ -327,6 +330,9 @@ func (p *Peer) PktProcess(data []byte, tap io.Writer, reorderable bool) bool {
                p.BusyR.Unlock()
                return true
        }
+       if int(p.pktSizeR) > len(data)-MinPktLength {
+               return false
+       }
        p.BytesPayloadIn += int64(p.pktSizeR)
        tap.Write(p.bufR[S20BS+PktSizeSize : S20BS+PktSizeSize+p.pktSizeR])
        p.BusyR.Unlock()