cmd/rlpdump, cmd/utils, eth, p2p, whisper: use rlp input limit

This commit is contained in:
Felix Lange
2015-03-23 15:08:29 +01:00
parent c35f4fd0bd
commit 56a48101dc
5 changed files with 8 additions and 7 deletions

View File

@ -32,7 +32,8 @@ type Msg struct {
//
// For the decoding rules, please see package rlp.
func (msg Msg) Decode(val interface{}) error {
if err := rlp.Decode(msg.Payload, val); err != nil {
s := rlp.NewStream(msg.Payload, uint64(msg.Size))
if err := s.Decode(val); err != nil {
return newPeerError(errInvalidMsg, "(code %x) (size %d) %v", msg.Code, msg.Size, err)
}
return nil