This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: zipfile: truncating comment can corrupt the zipfile
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alanmcintyre, georg.brandl, pitrou, python-dev, rfk, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2010-07-12 23:56 by rfk, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
zipfile_appendmode_comment.patch rfk, 2010-07-12 23:56
zipfile_appendmode_comment_tests.patch serhiy.storchaka, 2012-06-30 06:26 Patch for 3.3 with tests only review
Messages (8)
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?
msg159532 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-04-28 19:29
The bug is no longer there. Probably it is fixed in issue14399.
msg164337 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-06-29 17:43
Anyone may close the issue as "out of date"?
msg164339 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-06-29 17:47
> The bug is no longer there. Probably it is fixed in issue14399.

Then the tests may still be added to test_zipfile?
msg164371 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-06-30 06:26
> Then the tests may still be added to test_zipfile?

Yes, they may. Here is a patch with adapted for 3.3 tests only.
msg164388 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-06-30 15:34
New changeset e13c9f99fbae by Antoine Pitrou in branch '3.2':
Issue #9239: add tests for modifying zipfile comments in append mode.
http://hg.python.org/cpython/rev/e13c9f99fbae

New changeset b299b4279e13 by Antoine Pitrou in branch 'default':
Issue #9239: add tests for modifying zipfile comments in append mode.
http://hg.python.org/cpython/rev/b299b4279e13
msg164389 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-06-30 15:34
Thanks, committed!
History
Date User Action Args
2022-04-11 14:57:03adminsetgithub: 53485
2012-06-30 15:34:58pitrousetstatus: open -> closed
resolution: fixed
messages: + msg164389

stage: patch review -> resolved
2012-06-30 15:34:19python-devsetnosy: + python-dev
messages: + msg164388
2012-06-30 06:26:12serhiy.storchakasetfiles: + zipfile_appendmode_comment_tests.patch

messages: + msg164371
2012-06-29 17:47:23pitrousetpriority: high -> normal

nosy: + pitrou
messages: + msg164339

assignee: alanmcintyre ->
2012-06-29 17:43:45serhiy.storchakasetmessages: + msg164337
2012-04-28 19:29:42serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg159532
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