@cryptotaxi247 / kubo / commits / 517e2d121

quick fix for OOM panic that has been plaguing us

Jeromy committed May 1, 2015 at 23:24 UTC 517e2d121f6ba93ccbef09134c02ceebfe6850cc
1 file changed +8
p2p/crypto/secio/rw.go
+8
@@ -15,6 +15,10 @@ import (
15 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
16 )
17
18 +const MaxMsgSize = 8 * 1024 * 1024
19 +
20 +var ErrMaxMessageSize = errors.New("attempted to read message larger than max size")
21 +
22 // ErrMACInvalid signals that a MAC verification failed
23 var ErrMACInvalid = errors.New("MAC verification failed")
24
@@ -130,6 +134,10 @@ func (r *etmReader) Read(buf []byte) (int, error) {
134 return 0, err
135 }
136
137 + if fullLen > MaxMsgSize {
138 + return 0, ErrMaxMessageSize
139 + }
140 +
141 buf2 := buf
142 changed := false
143 // if not enough space, allocate a new buffer.