aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/downloader.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-05-15 06:40:16 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-05-15 20:01:58 +0800
commitcd2fb0905109828028172c84f9c10f1343647ca6 (patch)
treeede1984738a0d16f338341f7a1bc94e17381a715 /eth/downloader/downloader.go
parentc1f0d40e34a80f4453a9a54f90e2d4551c3bdb05 (diff)
downloaddexon-cd2fb0905109828028172c84f9c10f1343647ca6.tar
dexon-cd2fb0905109828028172c84f9c10f1343647ca6.tar.gz
dexon-cd2fb0905109828028172c84f9c10f1343647ca6.tar.bz2
dexon-cd2fb0905109828028172c84f9c10f1343647ca6.tar.lz
dexon-cd2fb0905109828028172c84f9c10f1343647ca6.tar.xz
dexon-cd2fb0905109828028172c84f9c10f1343647ca6.tar.zst
dexon-cd2fb0905109828028172c84f9c10f1343647ca6.zip
eth, eth/downloader: prevent hash repeater attack
Diffstat (limited to 'eth/downloader/downloader.go')
-rw-r--r--eth/downloader/downloader.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index 616971f73..3da606aef 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -27,7 +27,7 @@ var (
errLowTd = errors.New("peer's TD is too low")
ErrBusy = errors.New("busy")
errUnknownPeer = errors.New("peer's unknown or unhealthy")
- errBadPeer = errors.New("action from bad peer ignored")
+ ErrBadPeer = errors.New("action from bad peer ignored")
errNoPeers = errors.New("no peers to keep download active")
ErrPendingQueue = errors.New("pending items in queue")
ErrTimeout = errors.New("timeout")
@@ -266,9 +266,11 @@ out:
break
}
}
- d.queue.Insert(hashPack.hashes)
-
- if !done {
+ // Insert all the new hashes, but only continue if got something useful
+ inserts := d.queue.Insert(hashPack.hashes)
+ if inserts == 0 && !done {
+ return ErrBadPeer
+ } else if !done {
activePeer.getHashes(hash)
continue
}