aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/network/stream
diff options
context:
space:
mode:
authorAnton Evangelatov <anton.evangelatov@gmail.com>2018-08-14 22:03:56 +0800
committerBalint Gabor <balint.g@gmail.com>2018-08-14 22:03:56 +0800
commit97887d98da703a31040bceee13bce9ee77fca673 (patch)
treeffc9a8a6fba087b26d33c0ef6c939a19aaaad8c9 /swarm/network/stream
parent8a040de60bd6b740ebe87cd8e1fe6bfdb6635d2f (diff)
downloadgo-tangerine-97887d98da703a31040bceee13bce9ee77fca673.tar
go-tangerine-97887d98da703a31040bceee13bce9ee77fca673.tar.gz
go-tangerine-97887d98da703a31040bceee13bce9ee77fca673.tar.bz2
go-tangerine-97887d98da703a31040bceee13bce9ee77fca673.tar.lz
go-tangerine-97887d98da703a31040bceee13bce9ee77fca673.tar.xz
go-tangerine-97887d98da703a31040bceee13bce9ee77fca673.tar.zst
go-tangerine-97887d98da703a31040bceee13bce9ee77fca673.zip
swarm/network, swarm/storage: validate chunk size (#17397)
* swarm/network, swarm/storage: validate default chunk size * swarm/bmt, swarm/network, swarm/storage: update BMT hash initialisation * swarm/bmt: move segmentCount to tests * swarm/chunk: change chunk.DefaultSize to be untyped const * swarm/storage: add size validator * swarm/storage: add chunk size validation to localstore * swarm/storage: move validation from localstore to validator * swarm/storage: global chunk rules in MRU
Diffstat (limited to 'swarm/network/stream')
-rw-r--r--swarm/network/stream/delivery.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/swarm/network/stream/delivery.go b/swarm/network/stream/delivery.go
index fa210e300..36040339d 100644
--- a/swarm/network/stream/delivery.go
+++ b/swarm/network/stream/delivery.go
@@ -24,6 +24,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/p2p/discover"
+ cp "github.com/ethereum/go-ethereum/swarm/chunk"
"github.com/ethereum/go-ethereum/swarm/log"
"github.com/ethereum/go-ethereum/swarm/network"
"github.com/ethereum/go-ethereum/swarm/spancontext"
@@ -229,6 +230,11 @@ R:
for req := range d.receiveC {
processReceivedChunksCount.Inc(1)
+ if len(req.SData) > cp.DefaultSize+8 {
+ log.Warn("received chunk is bigger than expected", "len", len(req.SData))
+ continue R
+ }
+
// this should be has locally
chunk, err := d.db.Get(context.TODO(), req.Addr)
if err == nil {
@@ -244,6 +250,7 @@ R:
continue R
default:
}
+
chunk.SData = req.SData
d.db.Put(context.TODO(), chunk)