classification
Title: zipfile: truncating comment can corrupt the zipfile
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.3, Python 3.2
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: alanmcintyre Nosy List: alanmcintyre, georg.brandl, rfk
Priority: high Keywords: patch

Created on 2010-07-12 23:56 by rfk, last changed 2011-10-24 01:17 by pitrou.

Files
File name Uploaded Description Edit
zipfile_appendmode_comment.patch rfk, 2010-07-12 23:56 review
Messages (2)
msg110149 - (view) Author: Ryan Kelly (rfk) Date: 2010-07-12 23:56
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.
msg112544 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-08-02 20:51
Patch looks good to me.  Alan, can you comment?
History
Date User Action Args
2011-10-24 01:17:51pitrousetstage: patch review
type: performance -> behavior
versions: + Python 3.3
2010-12-25 19:37:51georg.brandlsetassignee: aimacintyre -> alanmcintyre
nosy: + alanmcintyre, - aimacintyre
2010-08-02 20:51:22georg.brandlsetpriority: normal -> high

nosy: + georg.brandl, aimacintyre
messages: + msg112544

assignee: aimacintyre
2010-07-12 23:56:44rfkcreate