| 1 |
|
| 2 |
"""Regression: a short transfer checksum must not over-state the block s2length. |
| 3 |
|
| 4 |
A full-checksum (--append-verify redo) pass computes the strong block sum length |
| 5 |
(s2length). The generator used to cap it at SUM_LENGTH (16), the legacy MD4/MD5 |
| 6 |
digest size, regardless of the negotiated algorithm. Since the sum2 array holds |
| 7 |
xfer_sum_len-byte elements and the sender rejects an s2length larger than |
| 8 |
xfer_sum_len, a sub-16-byte transfer checksum -- xxh64 (8 bytes), which is what |
| 9 |
rsync negotiates when the build's libxxhash lacks xxh128/xxh3 (e.g. Ubuntu |
| 10 |
20.04) -- made the sender die with "Invalid checksum length 16 [sender]" |
| 11 |
(protocol incompatibility, code 2). |
| 12 |
|
| 13 |
Forcing --checksum-choice=xxh64 reproduces it on any build that has xxhash, so |
| 14 |
this guards the fix without needing an old-libxxhash host. Skipped where xxh64 |
| 15 |
is unavailable (a build without xxhash). |
| 16 |
""" |
| 17 |
|
| 18 |
import json |
| 19 |
|
| 20 |
from rsyncfns import ( |
| 21 |
FROMDIR, TODIR, assert_same, make_data_file, rmtree, run_rsync, |
| 22 |
test_skipped, |
| 23 |
) |
| 24 |
|
| 25 |
vv = json.loads(run_rsync('-VV', check=True, capture_output=True).stdout) |
| 26 |
if 'xxh64' not in vv.get('checksum_list', []): |
| 27 |
test_skipped("xxh64 not in this build's checksum list (no xxhash)") |
| 28 |
|
| 29 |
src, dst = FROMDIR, TODIR |
| 30 |
rmtree(src) |
| 31 |
rmtree(dst) |
| 32 |
src.mkdir(parents=True) |
| 33 |
dst.mkdir(parents=True) |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
make_data_file(src / 'f', 40000) |
| 40 |
full = (src / 'f').read_bytes() |
| 41 |
prefix = bytearray(full[:20000]) |
| 42 |
prefix[0:64] = b'\x00' * 64 |
| 43 |
(dst / 'f').write_bytes(bytes(prefix)) |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
run_rsync('-a', '--append-verify', '--checksum-choice=xxh64', '--no-whole-file', |
| 48 |
f'{src}/', f'{dst}/') |
| 49 |
assert_same(dst / 'f', src / 'f', label='append-verify xxh64 redo') |
| 50 |
|
| 51 |
print("append-shortsum: --append-verify with an 8-byte (xxh64) checksum no " |
| 52 |
"longer overflows the block s2length") |