Skip to content

Commit 517e2d1

Browse files
committedMay 2, 2015
quick fix for OOM panic that has been plaguing us
1 parent cc5f6bb commit 517e2d1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎p2p/crypto/secio/rw.go

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import (
1515
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
1616
)
1717

18+
const MaxMsgSize = 8 * 1024 * 1024
19+
20+
var ErrMaxMessageSize = errors.New("attempted to read message larger than max size")
21+
1822
// ErrMACInvalid signals that a MAC verification failed
1923
var ErrMACInvalid = errors.New("MAC verification failed")
2024

@@ -130,6 +134,10 @@ func (r *etmReader) Read(buf []byte) (int, error) {
130134
return 0, err
131135
}
132136

137+
if fullLen > MaxMsgSize {
138+
return 0, ErrMaxMessageSize
139+
}
140+
133141
buf2 := buf
134142
changed := false
135143
// if not enough space, allocate a new buffer.

0 commit comments

Comments
 (0)