From 7fd9a1b6d5f6d792b4b8ad8c65a0aa9d52ec6a5c Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Fri, 11 Apr 2008 11:48:35 +0000 Subject: [PATCH] reject on presence/absence of un/expected checksums-* fields --- ChangeLog | 3 ++- dak/process_unchecked.py | 26 ++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 90475c4f..002339e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,8 @@ * dak/process_unchecked.py: check_md5sum becomes check_hashes and check_hash. If changes format is 1.8 or later, also check - checksums-sha1 and checksums-sha256 for both .changes and .dsc. + checksums-sha1 and checksums-sha256 for both .changes and .dsc, + and reject on presence/absence of un/expected checksums-* fields. 2008-04-07 Joerg Jaspert diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py index c4fcf4b7..30737ed1 100755 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -916,14 +916,32 @@ def check_hashes (): else: hashes = [] + for x in changes: + if x.startswith("checksum-"): + h = x.split("-",1)[1] + if h not in dict(hashes): + reject("Unsupported checksum field in .changes" % (h)) + + for x in dsc: + if x.startswith("checksum-"): + h = x.split("-",1)[1] + if h not in dict(hashes): + reject("Unsupported checksum field in .dsc" % (h)) + for h,f in hashes: - fs = daklib.utils.build_file_list(changes, 0, "checksums-%s" % h, h) - check_hash( ".changes %s" % (h), fs, h, f, files) + try: + fs = daklib.utils.build_file_list(changes, 0, "checksums-%s" % h, h) + check_hash(".changes %s" % (h), fs, h, f, files) + except daklib.utils.no_files_exc: + reject("No Checksums-%s: field in .changes file" % (h)) if "source" not in changes["architecture"]: continue - fs = daklib.utils.build_file_list(dsc, 1, "checksums-%s" % h, h) - check_hash( ".dsc %s" % (h), fs, h, f, dsc_files) + try: + fs = daklib.utils.build_file_list(dsc, 1, "checksums-%s" % h, h) + check_hash(".dsc %s" % (h), fs, h, f, dsc_files) + except daklib.utils.no_files_exc: + reject("No Checksums-%s: field in .changes file" % (h)) ################################################################################ -- 2.39.2