]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/govpn/peer.go
Raise copyright years
[govpn.git] / src / govpn / peer.go
index 1076e74bea38300f1e0531e3e9ebf52f94e58340..feb0ea45db855ad2fc6e12c397bc87fbc92b128e 100644 (file)
@@ -1,3 +1,21 @@
+/*
+GoVPN -- simple secure free software virtual private network daemon
+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
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
 package govpn
 
 import (
@@ -242,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)
@@ -309,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()