diff --git a/borg/testsuite/hashindex.py b/borg/testsuite/hashindex.py index 5fd9e304..78d166a9 100644 --- a/borg/testsuite/hashindex.py +++ b/borg/testsuite/hashindex.py @@ -284,3 +284,45 @@ def test_nsindex_segment_limit(): def test_max_load_factor(): assert NSIndex.MAX_LOAD_FACTOR < 1.0 assert ChunkIndex.MAX_LOAD_FACTOR < 1.0 + + +class IndexCorruptionTestCase(BaseTestCase): + def test_bug_4829(self): + + from struct import pack + + def HH(x, y): + # make some 32byte long thing that depends on x and y. + # same x will mean a collision in the hashtable as bucket index is computed from + # first 4 bytes. giving a specific x targets bucket index x. + # y is to create different keys and does not go into the bucket index calculation. + # so, same x + different y --> collision + return pack('