Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/borg/helpers/parseformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ def ChunkerParams(s):
raise ArgumentTypeError("max. chunk size exponent must not be more than 23 (2^23 = 8MiB max. chunk size)")
if window_size % 2 == 0:
raise ArgumentTypeError("window_size must be an uneven (odd) number")
# the chunker needs the hash window plus one byte beyond the min. chunk size to fit into
# a max. chunk size sized buffer, see the assertion in Chunker.__cinit__ (buzhash.pyx).
if window_size + 2**chunk_min + 1 > 2**chunk_max:
raise ArgumentTypeError("required: window_size + 2^chunk_min + 1 <= 2^chunk_max")
return CH_BUZHASH, chunk_min, chunk_max, chunk_mask, window_size
raise ArgumentTypeError("invalid chunker params")

Expand Down
3 changes: 3 additions & 0 deletions src/borg/testsuite/helpers/parseformat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,7 @@ def test_eval_escapes():
("19,23,21,4095", ("buzhash", 19, 23, 21, 4095)),
("buzhash,19,23,21,4095", ("buzhash", 19, 23, 21, 4095)),
("10,23,16,4095", ("buzhash", 10, 23, 16, 4095)),
("10,13,11,4095", ("buzhash", 10, 13, 11, 4095)), # just fits: 4095 + 1024 + 1 <= 8192
("buzhash64,19,23,21,4095,2", ("buzhash64", 19, 23, 21, 4095, 2)),
("fastcdc,19,23,21,2", ("fastcdc", 19, 23, 21, 2)),
("fixed,4096", ("fixed", 4096, 0)),
Expand All @@ -917,6 +918,8 @@ def test_valid_chunkerparams(chunker_params, expected_return):
"buzhash,23,19,21,4095", # violates min <= mask <= max
"buzhash,19,23,21,4096", # even window size
"buzhash,19,23,21", # missing window_size (must not fall into old-style compat mode)
"buzhash,10,12,11,4095", # window_size + 2^chunk_min + 1 > 2^chunk_max
"19,19,19,4095", # dito, chunk_min == chunk_max (old-style compat mode)
"buzhash64,20,20,20,4095,2", # window_size + 2^chunk_min + 1 > 2^chunk_max
"buzhash64,19,19,19,4095,2", # dito, chunk_min == chunk_max
"buzhash64,19,23,21,4095", # missing nc_level
Expand Down
Loading