[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-03-31 Thread Euler Taveira de Oliveira

New submission from Euler Taveira de Oliveira :

PyDict_SetItemString() fails when the second argument (key) is null
pointer. It occurs because PyString_FromString(key) call doesn't check
for null pointer and if we're in a disabled assert environment the
assert() is not caught and strlen() fails.

I don't know what is the best fix but we have two possibilities:

(i) check the second argument in PyDict_SetItemString() before calling
PyString_FromString() and returns null if that argument is null;
(ii) replace the assert() in PyString_FromString() to 'if (str == NULL)
return NULL;'.

This bug was reported as a PostgreSQL bug at [1].

[1] http://archives.postgresql.org/pgsql-hackers/2009-03/msg01344.php

--
components: Interpreter Core
messages: 84833
nosy: eulerto
severity: normal
status: open
title: PyDict_SetItemString() fails when the second argument is null
type: crash

___
Python tracker 

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



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-03-31 Thread Euler Taveira de Oliveira

Euler Taveira de Oliveira  added the comment:

It seems PyDict_DelItemString() and PyDict_SetItem() suffer from the
same disease. :( Both use assert() to detect a null pointer but fail to
prevent it. As I stated in the previous comment, maybe the right fix is
to replace assert() with the 'if (foo == NULL) return whatever'.

--

___
Python tracker 

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



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-03-31 Thread Georg Brandl

Georg Brandl  added the comment:

I am not sure why you consider this a bug. You should certainly not pass
NULL pointers around where the docs do not explicitly allow this.

--
nosy: +georg.brandl
resolution:  -> wont fix
status: open -> pending

___
Python tracker 

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



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-03-31 Thread Euler Taveira de Oliveira

Euler Taveira de Oliveira  added the comment:

I know that it is a good programming practice checking null pointers but
sometimes programmers are lazy. ;)  I still think that high level
functions should check for null pointers.

--

___
Python tracker 

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



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-04-01 Thread Georg Brandl

Georg Brandl  added the comment:

Raymond, do you have an opinion about this?

--
assignee:  -> rhettinger
nosy: +rhettinger

___
Python tracker 

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



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-04-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Martin, do you have any insight into this?  The values being seen and
the fact that it occurs only in a particular build suggests that
pyport.h has inconsistent definitions for Py_ssize_t, PY_SSIZE_T_MAX,
and PY_SSIZE_T_MIN.  The values look like signed and unsigned values are
being conflated.

--
assignee: rhettinger -> loewis
nosy: +loewis
status: pending -> open

___
Python tracker 

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



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-04-01 Thread Martin v. Löwis

Martin v. Löwis  added the comment:

> Martin, do you have any insight into this

Are you sure you commenting into the right issue?
How does Py_ssize_t come into play here?

--
title: PyDict_SetItemString() fails when the second argument is null -> 
PyDict_SetItemString() fails when the second argument isnull

___
Python tracker 

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



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-04-01 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--

___
Python tracker 

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



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-04-01 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--

___
Python tracker 

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



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-04-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I recommend rejecting this one.  The assert is sufficient for
third-party modules to run their tests and detect bad calls.  The code
path is too critical to add another check.

--
assignee: loewis -> georg.brandl

___
Python tracker 

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



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-04-01 Thread Georg Brandl

Georg Brandl  added the comment:

Closing.

--
status: open -> closed

___
Python tracker 

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