From 814865f0ccbbf9e6bebd03c9aff68f04ee3c2af2 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Sat, 7 Jan 2017 16:23:40 +0000 Subject: [PATCH] If you have no key (e.g. package not signed, but an .asc file exists with 404 html in it) the parse_key function goes completely splat. this patch wraps the splat-going bits into a try/except construct --- autospec/pkg_integrity.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/autospec/pkg_integrity.py b/autospec/pkg_integrity.py index 04034fd..a5c24c2 100644 --- a/autospec/pkg_integrity.py +++ b/autospec/pkg_integrity.py @@ -307,13 +307,17 @@ def parse_key(filename, pattern): Parse gpg --list-packet signature for pattern, return first match """ args = ["gpg", "--list-packet", filename] - out, err = Popen(args, stdout=PIPE, stderr=PIPE).communicate() - if err.decode('utf-8') != '': - print(err.decode('utf-8')) + try: + out, err = Popen(args, stdout=PIPE, stderr=PIPE).communicate() + if err.decode('utf-8') != '': + print(err.decode('utf-8')) + return None + out = out.decode('utf-8') + match = re.search(pattern, out) + return match.group(1).strip() if match else None + except: return None - out = out.decode('utf-8') - match = re.search(pattern, out) - return match.group(1).strip() if match else None + return None def get_keyid(sig_filename):