[Patches] [ python-Patches-873224 ] Marshal clean-up

SourceForge.net noreply at sourceforge.net
Fri Mar 26 10:24:57 EST 2004


Patches item #873224, was opened at 2004-01-08 18:29
Message generated for change (Settings changed) made by arigo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=873224&group_id=5470

Category: Core (C code)
Group: Python 2.4
>Status: Closed
Resolution: Accepted
Priority: 2
Submitted By: Armin Rigo (arigo)
Assigned to: Armin Rigo (arigo)
Summary: Marshal clean-up

Initial Comment:
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).

----------------------------------------------------------------------

>Comment By: Armin Rigo (arigo)
Date: 2004-03-26 15:24

Message:
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.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2004-03-26 13:38

Message:
Logged In: YES 
user_id=21627

The patch is fine, please apply.

----------------------------------------------------------------------

Comment By: Armin Rigo (arigo)
Date: 2004-01-08 19:00

Message:
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


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2004-01-08 18:55

Message:
Logged In: YES 
user_id=6656

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

Needs testcases!

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=873224&group_id=5470



More information about the Patches mailing list