On May 13, 2008, at 10:17pm, Kalle Olavi Niemitalo writes:
>I think we should copy this code snippet from the public-domain
>PEP 353 <http://www.python.org/dev/peps/pep-0353/>:
>
>#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
>typedef int Py_ssize_t;
>#define PY_SSIZE_T_MAX INT_MAX
>#define PY_SSIZE_T_MIN INT_MIN
>#endif
>
>into src/scripting/python/core.h, with a comment saying where it
>came from.  Then also change python_menu() to use Py_ssize_t for
>the result of PySequence_Length(items) and return NULL if length
>exceeds INT_MAX.  That and script_hook_pre_format_html() are the
>only relevant uses of int in /src/scripting/python/, I think.

For what it's worth, I looked into this at one point and came to the same
conclusions as you did above. But as I recall, I was still left wondering
if there's a sufficiently portable way to determine whether a Py_ssize_t
value could overflow an off_t when the len from PyString_AsStringAndSize()
is passed to normalize_cache_entry(), which takes an off_t parameter. Was
I missing something obvious?
_______________________________________________
elinks-dev mailing list
elinks-dev@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-dev

Reply via email to