kovidgoyal/kitty · error
rsync signature header has zero block size
Error message
rsync signature header has zero block size
What it means
The rsync signature header's block-size field (bytes 8-11, big-endian uint32) read as zero, which is invalid — blocks must have a positive size.
Source
Thrown at tools/rsync/api.go:101
return consumed, fmt.Errorf("Invalid checksum_type in signature header: %d", csum)
}
switch strong_hash := StrongHashType(bin.Uint16(data[4:])); strong_hash {
case XXH3:
self.Strong_hash_type = strong_hash
self.rsync.SetHasher(new_xxh3_64)
default:
return consumed, fmt.Errorf("Invalid strong_hash in signature header: %d", strong_hash)
}
switch weak_hash := WeakHashType(bin.Uint16(data[6:])); weak_hash {
case Rsync:
self.Weak_hash_type = weak_hash
default:
return consumed, fmt.Errorf("Invalid weak_hash in signature header: %d", weak_hash)
}
block_size := int(bin.Uint32(data[8:]))
consumed = 12
if block_size == 0 {
return consumed, fmt.Errorf("rsync signature header has zero block size")
}
if block_size > MaxBlockSize {
return consumed, fmt.Errorf("rsync signature header has too large block size %d > %d", block_size, MaxBlockSize)
}
self.rsync.BlockSize = block_size
self.signature = make([]BlockHash, 0, 1024)
return
}
func (self *Api) read_signature_blocks(data []byte) (consumed int) {
block_hash_size := self.rsync.HashSize() + 12
for ; len(data) >= block_hash_size; data = data[block_hash_size:] {
bl := BlockHash{}
bl.Unserialize(data[:block_hash_size])
self.signature = append(self.signature, bl)
consumed += block_hash_size
}
returnView on GitHub (pinned to 6d5d0c4406)
Solutions
- Confirm the data passed to AddSignatureData begins with a real signature header
- Check for off-by-one offsets or extra framing bytes before the signature
- Regenerate the signature from the source file
Defensive patterns
Strategy: try-catch
Validate before calling
if len(data) < 12 { return fmt.Errorf("header truncated") }
if binary.BigEndian.Uint32(data[8:12]) == 0 { return fmt.Errorf("zero block size") } Try / catch
if err := differ.AddSignatureData(chunk); err != nil { abort transfer; regenerate signature } Prevention
- Use CreateSignatureIterator output verbatim; don't reframe bytes
- Checksum transfers to detect corruption early
When it happens
Trigger: AddSignatureData receiving a 12+ byte header whose block-size field is 0 — almost always a corrupted, misaligned, or hand-crafted stream rather than a real signature.
Common situations: Stream misalignment (reading from the wrong offset), truncation, or feeding random/test bytes into AddSignatureData without a valid header.
Related errors
- Invalid weak_hash in signature header: %d
- rsync signature header has too large block size %d > %d
- There were %d leftover bytes in the signature data
- There are %d leftover bytes in the delta
- The checksum was not received at the end of the delta data
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/3ed1df94c1396a23.
Report an issue: GitHub.