From 6b6fdda2f6447c3ecddfb45e88b0f3bcacc5f082 Mon Sep 17 00:00:00 2001 From: razzeee Date: Mon, 8 Jun 2026 10:34:38 +0200 Subject: [PATCH] flatpak-coredumpctl: Guard against unexpected coredumpctl output The bare tuple unpack 'executable, = re.findall(...)' raises a cryptic ValueError if the pattern matches zero or more than one line. Replace it with an explicit length check and a clear error message. Also pass count=1 to str.replace() so a /newroot prefix is only stripped once and /app/ paths are passed through unchanged. --- scripts/flatpak-coredumpctl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/flatpak-coredumpctl b/scripts/flatpak-coredumpctl index 123281fcf..f9df08fb2 100755 --- a/scripts/flatpak-coredumpctl +++ b/scripts/flatpak-coredumpctl @@ -60,11 +60,17 @@ class CoreDumper(): sys.exit(dumpres.returncode) - executable, = re.findall(".*Executable: (.*)", dumpres.stderr) + matches = re.findall(r".*Executable: (.*)", dumpres.stderr) + if len(matches) != 1: + print(f"Could not determine executable from coredumpctl output " + f"(found {len(matches)} 'Executable:' line(s)).", + file=sys.stderr) + sys.exit(1) + executable = matches[0] if not executable.startswith(("/newroot/", "/app/")): print(f"Executable {executable} doesn't seem to be a flatpaked application.", file=sys.stderr) - executable = executable.replace("/newroot", "") + executable = executable.replace("/newroot", "", 1) flatpak_command.extend([executable, coredump.name]) flatpak_command.extend(shlex.split(self.gdb_arguments))