Skip to content

Commit

Permalink
add chunk validation to netStore.addStoreRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
zelig committed Jun 22, 2015
1 parent 89a05fc commit d8d5b69
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bzz/netstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d8d5b69

Please sign in to comment.