Skip to content

Commit

Permalink
zstd: Disable extended memory copies (amd64) (#644)
Browse files Browse the repository at this point in the history
Using longer memory copies leads to rare, random crashes with fuzz testing.

It is therefore disabled for now.
  • Loading branch information
klauspost authored Jul 17, 2022
1 parent b017051 commit 03c136c
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions zstd/seqdec_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,22 @@ func (s *sequenceDecs) decodeSyncSimple(hist []byte) (bool, error) {
if s.maxSyncLen == 0 && cap(s.out)-len(s.out) < maxCompressedBlockSize {
return false, nil
}
useSafe := false
if s.maxSyncLen == 0 && cap(s.out)-len(s.out) < maxCompressedBlockSizeAlloc {
useSafe = true
}
if s.maxSyncLen > 0 && cap(s.out)-len(s.out)-compressedBlockOverAlloc < int(s.maxSyncLen) {
useSafe = true
}
if cap(s.literals) < len(s.literals)+compressedBlockOverAlloc {
useSafe = true
}

// FIXME: Using unsafe memory copies leads to rare, random crashes
// with fuzz testing. It is therefore disabled for now.
const useSafe = true
/*
useSafe := false
if s.maxSyncLen == 0 && cap(s.out)-len(s.out) < maxCompressedBlockSizeAlloc {
useSafe = true
}
if s.maxSyncLen > 0 && cap(s.out)-len(s.out)-compressedBlockOverAlloc < int(s.maxSyncLen) {
useSafe = true
}
if cap(s.literals) < len(s.literals)+compressedBlockOverAlloc {
useSafe = true
}
*/

br := s.br

Expand Down

0 comments on commit 03c136c

Please sign in to comment.