mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-03 04:37:30 +08:00
quick fix for OOM panic that has been plaguing us
This commit is contained in:
@ -15,6 +15,10 @@ import (
|
|||||||
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const MaxMsgSize = 8 * 1024 * 1024
|
||||||
|
|
||||||
|
var ErrMaxMessageSize = errors.New("attempted to read message larger than max size")
|
||||||
|
|
||||||
// ErrMACInvalid signals that a MAC verification failed
|
// ErrMACInvalid signals that a MAC verification failed
|
||||||
var ErrMACInvalid = errors.New("MAC verification failed")
|
var ErrMACInvalid = errors.New("MAC verification failed")
|
||||||
|
|
||||||
@ -130,6 +134,10 @@ func (r *etmReader) Read(buf []byte) (int, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fullLen > MaxMsgSize {
|
||||||
|
return 0, ErrMaxMessageSize
|
||||||
|
}
|
||||||
|
|
||||||
buf2 := buf
|
buf2 := buf
|
||||||
changed := false
|
changed := false
|
||||||
// if not enough space, allocate a new buffer.
|
// if not enough space, allocate a new buffer.
|
||||||
|
Reference in New Issue
Block a user