Skip to content

Commit ef47e96

Browse files
authored
fix: consider RLE blocks in zstd compatibility check (#64)
* fix compability * fmt
1 parent b4cce5c commit ef47e96

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

encoding/da.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,16 @@ func checkCompressedDataCompatibilityV7(data []byte) error {
495495
// scan each block until done
496496
for len(data) > 3 && !isLast {
497497
isLast = (data[0] & 1) == 1
498-
blkSize := (uint(data[2])*65536 + uint(data[1])*256 + uint(data[0])) >> 3
498+
blkType := (data[0] >> 1) & 3
499+
var blkSize uint
500+
if blkType == 1 { // RLE Block
501+
blkSize = 1
502+
} else {
503+
if blkType == 3 {
504+
return fmt.Errorf("encounter reserved block type at %v", data)
505+
}
506+
blkSize = (uint(data[2])*65536 + uint(data[1])*256 + uint(data[0])) >> 3
507+
}
499508
if len(data) < 3+int(blkSize) {
500509
return fmt.Errorf("wrong data len {%d}, expect min {%d}", len(data), 3+blkSize)
501510
}

0 commit comments

Comments
 (0)