From 89a05fc89345d7e121091793ebe16e75ebb5b221 Mon Sep 17 00:00:00 2001 From: zelig Date: Mon, 22 Jun 2015 10:57:46 +0100 Subject: [PATCH 1/2] check timeout for nil when propagage response --- bzz/netstore.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bzz/netstore.go b/bzz/netstore.go index 8fc843fceb66..9a220c2d21ed 100644 --- a/bzz/netstore.go +++ b/bzz/netstore.go @@ -287,7 +287,6 @@ func (self *netStore) strategyUpdateRequest(rs *requestStatus, origReq *retrieve } } return - } // once a chunk is found propagate it its requesters unless timed out @@ -302,7 +301,7 @@ func (self *netStore) propagateResponse(chunk *Chunk) { Id: uint64(id), } for _, req := range requesters { - if req.timeout.After(time.Now()) { + if req.timeout == nil || req.timeout.After(time.Now()) { glog.V(logger.Debug).Infof("netStore.propagateResponse store -> %064x with %v", req.Id, req.peer) go req.peer.store(msg) counter-- From d8d5b699bff46a2fbf0aaccee4438ca680021f15 Mon Sep 17 00:00:00 2001 From: zelig Date: Mon, 22 Jun 2015 11:17:54 +0100 Subject: [PATCH 2/2] add chunk validation to netStore.addStoreRequest --- bzz/netstore.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bzz/netstore.go b/bzz/netstore.go index 9a220c2d21ed..9f77432a4216 100644 --- a/bzz/netstore.go +++ b/bzz/netstore.go @@ -140,9 +140,19 @@ func (self *netStore) addStoreRequest(req *storeRequestMsgData) { Size: int64(binary.LittleEndian.Uint64(req.SData[0:8])), } } else if chunk.SData == nil { + // need data, validate now + hasher := hasherfunc.New() + hasher.Write(data) + if !bytes.Equal(hasher.Sum(nil), key) { + // data does not validate, ignore + glog.V(logger.Warn).Infof("netStore.addStoreRequest: chunk invalid. store request ignored: %v", req) + return + } + chunk.SData = req.SData chunk.Size = int64(binary.LittleEndian.Uint64(req.SData[0:8])) } else { + // data is found, store request ignored return } chunk.source = req.peer