[issue25961] Disallow the null character in type name

2015-12-31 Thread Florin Papa

Florin Papa added the comment:

Hi all,

I fixed a compile error introduced in Python 2.7 by this issue. There is a jump 
made to an nonexistent label "error" in type_new function in 
Objects/typeobject.c. Please see the attached patch.

Regards,
Florin Papa

--
nosy: +florin.papa
Added file: http://bugs.python.org/file41460/type_name_null_fix.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25961] Disallow the null character in type name

2015-12-31 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 57fea6f75ac2 by Serhiy Storchaka in branch '2.7':
Issue #25961: Fixed compilation error and a leak in type constructor.
https://hg.python.org/cpython/rev/57fea6f75ac2

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25961] Disallow the null character in type name

2015-12-31 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Florin. How could I miss this?

But your patch is not correct. It leads to double free and deallocating using 
non-initialized pointer. It also contains trailing spaces and incorrect 
indentation.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25961] Disallow the null character in type name

2015-12-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 29cc6b2f9d28 by Serhiy Storchaka in branch '2.7':
Issue #25961: Disallowed null characters in the type name.
https://hg.python.org/cpython/rev/29cc6b2f9d28

New changeset d2417971c934 by Serhiy Storchaka in branch '3.5':
Issue #25961: Disallowed null characters in the type name.
https://hg.python.org/cpython/rev/d2417971c934

New changeset 1ab7bcd4e176 by Serhiy Storchaka in branch 'default':
Issue #25961: Disallowed null characters in the type name.
https://hg.python.org/cpython/rev/1ab7bcd4e176

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25961] Disallow the null character in type name

2015-12-29 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Because tp_name is a pointer to null-terminated C string and there is no way to 
distinguish the name containg the null byte from the name terminated by null 
byte. tp_name is used for example in error messages.

>>> t = type('B\0C', (), {})
>>> t.__name__
'B\x00C'
>>> t() + 0
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for +: 'B' and 'int'

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25961] Disallow the null character in type name

2015-12-29 Thread ppperry

ppperry added the comment:

Why are null bytes being excluded from type names in the first place?

--
nosy: +ppperry

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25961] Disallow the null character in type name

2015-12-27 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
keywords: +patch
stage: needs patch -> patch review
Added file: http://bugs.python.org/file41434/type_name_null.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25961] Disallow the null character in type name

2015-12-27 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

The null character is allowed in __name__ setter (but error message is a little 
confusing).

>>> class A: pass
... 
>>> A.__name__ = 'B\0'
Traceback (most recent call last):
  File "", line 1, in 
ValueError: __name__ must not contain null bytes

But is allowed in type constructor.

>>> t = type('B\0C', (), {})
>>> t

>>> t.__name__
'B\x00C'

--
components: Interpreter Core
messages: 257076
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: needs patch
status: open
title: Disallow the null character in type name
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com