diff --git a/main.go b/main.go index c1c654446..74703e1db 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/protocol/marshal.go b/protocol/marshal.go index decd2c136..74e554d57 100644 --- a/protocol/marshal.go +++ b/protocol/marshal.go @@ -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))