aboutsummaryrefslogtreecommitdiffstats
path: root/peer.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-30 17:48:23 +0800
committerobscuren <geffobscura@gmail.com>2014-05-30 17:48:23 +0800
commit15e0093e13dde98fb9ff3251203313ab4f0eacd4 (patch)
tree0fd64860d9b81dbc25a9afdbb5b49ee6d8115875 /peer.go
parent99797858a692520b47c2ca767b433ca425637d2a (diff)
downloadgo-tangerine-15e0093e13dde98fb9ff3251203313ab4f0eacd4.tar
go-tangerine-15e0093e13dde98fb9ff3251203313ab4f0eacd4.tar.gz
go-tangerine-15e0093e13dde98fb9ff3251203313ab4f0eacd4.tar.bz2
go-tangerine-15e0093e13dde98fb9ff3251203313ab4f0eacd4.tar.lz
go-tangerine-15e0093e13dde98fb9ff3251203313ab4f0eacd4.tar.xz
go-tangerine-15e0093e13dde98fb9ff3251203313ab4f0eacd4.tar.zst
go-tangerine-15e0093e13dde98fb9ff3251203313ab4f0eacd4.zip
Fixed issue where the client could crash when sending malformed data
Diffstat (limited to 'peer.go')
-rw-r--r--peer.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/peer.go b/peer.go
index 3d140608b..60f2de711 100644
--- a/peer.go
+++ b/peer.go
@@ -450,9 +450,11 @@ func (p *Peer) HandleInbound() {
//ethutil.Config.Log.Debugf("[PEER] Could not find a similar block")
// If no blocks are found we send back a reply with msg not in chain
// and the last hash from get chain
- lastHash := msg.Data.Get(l - 1)
- //log.Printf("Sending not in chain with hash %x\n", lastHash.AsRaw())
- p.QueueMessage(ethwire.NewMessage(ethwire.MsgNotInChainTy, []interface{}{lastHash.Raw()}))
+ if l > 0 {
+ lastHash := msg.Data.Get(l - 1)
+ //log.Printf("Sending not in chain with hash %x\n", lastHash.AsRaw())
+ p.QueueMessage(ethwire.NewMessage(ethwire.MsgNotInChainTy, []interface{}{lastHash.Raw()}))
+ }
}
case ethwire.MsgNotInChainTy:
ethutil.Config.Log.Debugf("Not in chain: %x\n", msg.Data.Get(0).Bytes())