Crash for explainable reason when protocol is out of sync (version skew)

This commit is contained in:
Jakob Borg 2013-12-15 13:18:03 +01:00
parent 8589a0fb40
commit e86296884a
2 changed files with 6 additions and 1 deletions

View File

@ -153,7 +153,7 @@ func main() {
// Walk the repository and update the local model before establishing any
// connections to other nodes.
infoln("Iniial repository scan in progress")
infoln("Initial repository scan in progress")
loadIndex(m)
updateLocalModel(m)

View File

@ -91,6 +91,11 @@ func (r *marshalReader) readBytes() []byte {
if r.err != nil {
return nil
}
if l > 10*1<<20 {
// Individual blobs in BEP are not significantly larger than BlockSize.
// BlockSize is not larger than 1MB.
panic("too large read - protocol error or out of sync")
}
b := buffers.Get(l + pad(l))
_, r.err = io.ReadFull(r.r, b)
r.tot += int(l + pad(l))