Re: [Python-Dev] Changing string constants to byte arrays ([Python-checkins] r55119 - in python/branches/py3k-struni/Lib: codecs.py test/test_codecs.py)

2007-05-04 Thread M.-A. Lemburg
Hi Walter,

if the bytes type does turn out to be a mutable type as suggested
in PEP 358, then please make sure that no code (C code in
particular), relies on the constantness of these byte objects.

This is especially important when it comes to codecs, since
the error callback logic would allow the callback to manipulate
the byte object contents and length without the codec taking
note of this change.

I expect there to be other places in the interpreter which would
break as well.

Otherwise, you end up opening the door for segfaults and
easy DOS attacks on Python3.

Regards,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 04 2007)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611


On 2007-05-04 15:05, walter.doerwald wrote:
 Author: walter.doerwald
 Date: Fri May  4 15:05:09 2007
 New Revision: 55119
 
 Modified:
python/branches/py3k-struni/Lib/codecs.py
python/branches/py3k-struni/Lib/test/test_codecs.py
 Log:
 Make the BOM constants in codecs.py bytes.
 
 Make the buffered input for decoders a bytes object.
 


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Changing string constants to byte arrays ([Python-checkins] r55119 - in python/branches/py3k-struni/Lib: codecs.py test/test_codecs.py)

2007-05-04 Thread Walter Dörwald
M.-A. Lemburg wrote:

 Hi Walter,
 
 if the bytes type does turn out to be a mutable type as suggested
 in PEP 358,

it is.

 then please make sure that no code (C code in
 particular), relies on the constantness of these byte objects.
 
 This is especially important when it comes to codecs, since
 the error callback logic would allow the callback to manipulate
 the byte object contents and length without the codec taking
 note of this change.

Encoding is not a problem because the error callback never sees or
returns a byte object.

However decoding is a problem. After the callback returns the codec has
to recalculate it's variables.

 I expect there to be other places in the interpreter which would
 break as well.
 
 Otherwise, you end up opening the door for segfaults and
 easy DOS attacks on Python3.

True, registering an even callback could crash the interpreter.

Seems we have to update all decoding functions.

Servus,
   Walter

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Changing string constants to byte arrays ([Python-checkins] r55119 - in python/branches/py3k-struni/Lib: codecs.py test/test_codecs.py)

2007-05-04 Thread Georg Brandl
M.-A. Lemburg schrieb:
 Hi Walter,
 
 if the bytes type does turn out to be a mutable type as suggested
 in PEP 358, then please make sure that no code (C code in
 particular), relies on the constantness of these byte objects.
 
 This is especially important when it comes to codecs, since
 the error callback logic would allow the callback to manipulate
 the byte object contents and length without the codec taking
 note of this change.
 
 I expect there to be other places in the interpreter which would
 break as well.
 
 Otherwise, you end up opening the door for segfaults and
 easy DOS attacks on Python3.

If the user does not need to change these bytes objects and this is needed
in more places, adding an immutable flag for internal bytes objects
only settable from C, or even an immutable byte base class might be an idea.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Changing string constants to byte arrays ([Python-checkins] r55119 - in python/branches/py3k-struni/Lib: codecs.py test/test_codecs.py)

2007-05-04 Thread M.-A. Lemburg
On 2007-05-04 18:53, Georg Brandl wrote:
 M.-A. Lemburg schrieb:
 Hi Walter,

 if the bytes type does turn out to be a mutable type as suggested
 in PEP 358, then please make sure that no code (C code in
 particular), relies on the constantness of these byte objects.

 This is especially important when it comes to codecs, since
 the error callback logic would allow the callback to manipulate
 the byte object contents and length without the codec taking
 note of this change.

 I expect there to be other places in the interpreter which would
 break as well.

 Otherwise, you end up opening the door for segfaults and
 easy DOS attacks on Python3.
 
 If the user does not need to change these bytes objects and this is needed
 in more places, adding an immutable flag for internal bytes objects
 only settable from C, or even an immutable byte base class might be an idea.

+1

I also suggest making all bytes literals immutable to avoid running
into any issues like the above.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 04 2007)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com