[New-bugs-announce] [issue9239] zipfile: truncating comment can corrupt the zipfile

Ryan Kelly report at bugs.python.org
Tue Jul 13 01:56:46 CEST 2010

New submission from Ryan Kelly <ryan at rfk.id.au>:

If you open a ZipFile in append mode and modify the comment to be shorter than what was originally there, the file will become corrupted.  Truncated data from the original comment is left "dangling" at the end of the zipfile.

A much more trivial bug discovered while writing tests for this: setting the "comment" attribute doesn't mark the zipfile as modified, so the change won't be written out unless you also modify one of the archive files.

The attached patch fixes (and adds tests for) these issues.

components: Library (Lib)
files: zipfile_appendmode_comment.patch
keywords: patch
messages: 110149
nosy: rfk
priority: normal
severity: normal
status: open
title: zipfile: truncating comment can corrupt the zipfile
type: performance
versions: Python 3.2
Added file: http://bugs.python.org/file17974/zipfile_appendmode_comment.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list