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: Marshal clean-up
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: arigo Nosy List: arigo, loewis, mwh
Priority: low Keywords: patch

Created on 2004-01-08 18:29 by arigo, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
marshal_cleanup.diff arigo, 2004-01-08 18:29 Cleanup of marshal.c.
test_marshal.diff arigo, 2004-01-08 19:00 Test cases for test_marchal.py
Messages (5)
msg45210 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2004-01-08 18:29
Reading random bytes with the marshal module can segfault the interpreter.  Moreover, reading a truncated .pyc file can also successfully return a (corrupted) object instead of raising an error.

Please review the attached patch if you consider this to be worth fixing.

The patch also fixes a minor bug in import.c, which would sometimes write incomplete .pyc files in case of write error (and hence the truncated .pyc file problems could actually show up, in theory).
msg45211 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-01-08 18:55
Logged In: YES 
user_id=6656

This patch results from my comments on IRC, so I'll take a look at it.

Needs testcases!
msg45212 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2004-01-08 19:00
Logged In: YES 
user_id=4771

Test cases:

>>> marshal.loads('0') -> SystemError
>>> marshal.loads('f') -> segfault

>>> marshal.dumps(5L)
'l\x01\x00\x00\x00\x05\x00'
>>> marshal.loads(_[:-1])
65285L
msg45213 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-03-26 13:38
Logged In: YES 
user_id=21627

The patch is fine, please apply.
msg45214 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2004-03-26 15:24
Logged In: YES 
user_id=4771

Python/marshal.c          rev 1.76
Python/import.c           rev 2.229
Lib/test/test_marshal.py  rev 1.6

Misformed .pyc files crashing Python is a bug that has been along for so long and people didn't complain, so I assume there is little point in bothering to back-port it to 2.3.
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39790
2004-01-08 18:29:01arigocreate