From a39e6c46c906f7ffbd9d03cee58d235e366ba00c Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Fri, 10 Jul 2009 18:53:33 +0100 Subject: [PATCH] apport: ensure temporary core files are removed Set unlink_core=True immediately after opening the temporary file so that it gets properly deleted in case there are errors while writing to it. In my testing the following exception occurred: Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/apport/report.py", line 411, in add_gdb_info self['CoreDump'].write(open(core, 'w')) File "/usr/lib/python2.5/site-packages/problem_report.py", line 67, in write block = gz.read(1048576) File "/usr/lib/python2.5/gzip.py", line 227, in read self._read(readsize) File "/usr/lib/python2.5/gzip.py", line 275, in _read self._read_eof() File "/usr/lib/python2.5/gzip.py", line 311, in _read_eof raise IOError, "CRC check failed" Fixes: #5309 --- apport/report.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apport/report.py b/apport/report.py index 828fc89..d1e9ccc 100644 --- a/apport/report.py +++ b/apport/report.py @@ -401,14 +401,14 @@ class Report(ProblemReport): try: if hasattr(self['CoreDump'], 'find'): (fd, core) = tempfile.mkstemp() + unlink_core = True os.write(fd, self['CoreDump']) os.close(fd) - unlink_core = True elif hasattr(self['CoreDump'], 'gzipvalue'): (fd, core) = tempfile.mkstemp() + unlink_core = True os.close(fd) self['CoreDump'].write(open(core, 'w')) - unlink_core = True else: core = self['CoreDump'][0] -- 1.5.6.3