Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Fix VerifyValueChecksum checks (#1138)
Browse files Browse the repository at this point in the history
Fixes dgraph-io/badger#1127 

The issue was that the crc32 value read from log was included when
recomputing hash value for verification.
  • Loading branch information
tuesmiddt authored and Ibrahim Jarif committed Dec 6, 2019
1 parent 647fa62 commit 0faee25
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion badger/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ func (vlog *valueLog) Read(vp valuePointer, s *y.Slice) ([]byte, func(), error)

if vlog.opt.VerifyValueChecksum {
hash := crc32.New(y.CastagnoliCrcTable)
if _, err := hash.Write(buf); err != nil {
if _, err := hash.Write(buf[:len(buf)-crc32.Size]); err != nil {
runCallback(cb)
return nil, nil, errors.Wrapf(err, "failed to write hash for vp %+v", vp)
}
Expand Down

0 comments on commit 0faee25

Please sign in to comment.