mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 01:04:14 +00:00
This fixes the change in #6674 where the weak hash became a deciding factor. Now we again just use it to accept a block, but don't take a negative as meaning the block is bad.
This commit is contained in:
parent
9f92f8c609
commit
fc1dac5196
@ -109,11 +109,11 @@ func Blocks(ctx context.Context, r io.Reader, blocksize int, sizehint int64, cou
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate quickly validates buf against the 32-bit weakHash, if not zero,
|
// Validate quickly validates buf against the 32-bit weakHash, if not zero,
|
||||||
// else against the cryptohash hash, if len(hash)>0.
|
// else against the cryptohash hash, if len(hash)>0. It is satisfied if
|
||||||
// It is satisfied if neither hash is given.
|
// either hash matches or neither hash is given.
|
||||||
func Validate(buf, hash []byte, weakHash uint32) bool {
|
func Validate(buf, hash []byte, weakHash uint32) bool {
|
||||||
if weakHash != 0 {
|
if weakHash != 0 && adler32.Checksum(buf) == weakHash {
|
||||||
return adler32.Checksum(buf) == weakHash
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(hash) > 0 {
|
if len(hash) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user