Commit 56a48101 authored by Felix Lange's avatar Felix Lange

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

parent c35f4fd0
......@@ -78,7 +78,7 @@ func main() {
os.Exit(2)
}
s := rlp.NewStream(r)
s := rlp.NewStream(r, 0)
for {
if err := dump(s, 0); err != nil {
if err != io.EOF {
......
......@@ -154,7 +154,7 @@ func ImportChain(chainmgr *core.ChainManager, fn string) error {
defer fh.Close()
chainmgr.Reset()
stream := rlp.NewStream(fh)
stream := rlp.NewStream(fh, 0)
var i, n int
batchSize := 2500
......
......@@ -210,7 +210,7 @@ func (self *ethProtocol) handle() error {
return p2p.Send(self.rw, BlockHashesMsg, hashes)
case BlockHashesMsg:
msgStream := rlp.NewStream(msg.Payload)
msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size))
if _, err := msgStream.List(); err != nil {
return err
}
......@@ -231,7 +231,7 @@ func (self *ethProtocol) handle() error {
self.blockPool.AddBlockHashes(iter, self.id)
case GetBlocksMsg:
msgStream := rlp.NewStream(msg.Payload)
msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size))
if _, err := msgStream.List(); err != nil {
return err
}
......@@ -259,7 +259,7 @@ func (self *ethProtocol) handle() error {
return p2p.Send(self.rw, BlocksMsg, blocks)
case BlocksMsg:
msgStream := rlp.NewStream(msg.Payload)
msgStream := rlp.NewStream(msg.Payload, uint64(msg.Size))
if _, err := msgStream.List(); err != nil {
return err
}
......
......@@ -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
......
......@@ -66,7 +66,7 @@ func (self *peer) handshake() error {
if packet.Code != statusCode {
return fmt.Errorf("peer sent %x before status packet", packet.Code)
}
s := rlp.NewStream(packet.Payload)
s := rlp.NewStream(packet.Payload, uint64(packet.Size))
if _, err := s.List(); err != nil {
return fmt.Errorf("bad status message: %v", err)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment