Skip to content
Snippets Groups Projects
Commit 8b90ec1a authored by Alexis Murzeau's avatar Alexis Murzeau Committed by Chris Lamb
Browse files

comparators/deb: Fix matching for .deb archive members. (Closes: #903565)


my_members is iterated in DebContainer.perform_fuzzy_matching but is modified
in Container.comparisons.prep_yield which remove the current item from
my_members.

This causes an `RuntimeError: OrderedDict mutated during iteration` error.
This was not detected by the existing `test_deb.test_compare_different_compression`
test as it triggers only when there is more than one file in the .deb file.
(That test use only one file: control.tar.{gz,xz}).

Signed-off-by: Chris Lamb's avatarChris Lamb <lamby@debian.org>
parent fc0ae562
No related branches found
No related tags found
No related merge requests found
Pipeline #16455 failed
......@@ -91,6 +91,11 @@ class DebContainer(LibarchiveContainer):
def perform_fuzzy_matching(self, my_members, other_members):
matched = set()
# Create local copies because they will be modified by consumer
my_members = dict(my_members)
other_members = dict(other_members)
for name1 in my_members.keys():
main, ext = os.path.splitext(name1)
candidates = [name2 for name2 in other_members.keys() - matched
......
......@@ -34,7 +34,7 @@ def perform_fuzzy_matching(members1, members2):
if tlsh is None or Config().fuzzy_threshold == 0:
return
already_compared = set()
# Perform local copies because they will be modified by consumer
# Create local copies because they will be modified by consumer
members1 = dict(members1)
members2 = dict(members2)
for name1, (file1, _) in members1.items():
......
......@@ -134,6 +134,9 @@ bug903391_deb1 = load_fixture('bug903391_1.deb')
bug903391_deb2 = load_fixture('bug903391_2.deb')
bug903401_deb1 = load_fixture('bug903401_1.deb')
bug903401_deb2 = load_fixture('bug903401_2.deb')
bug903565_deb1 = load_fixture('bug903565_1.deb')
bug903565_deb2 = load_fixture('bug903565_2.deb')
@skip_unless_tools_exist('xz')
......@@ -151,3 +154,7 @@ def test_uncompressed_data_tar(bug903401_deb1, bug903401_deb2):
def test_uncompressed_control_tar(bug903391_deb1, bug903391_deb2):
bug903391_deb1.compare(bug903391_deb2)
def test_compare_different_compression_multiple_files(bug903565_deb1, bug903565_deb2):
bug903565_deb1.compare(bug903565_deb2)
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment