Eryk Sun added the comment:

> Now we have an example, and can backport that patch.

More seriously it's possible to get a buffer over-read using NumPy:

    >>> import numpy
    >>> int(buffer(numpy.array('123', dtype='c')))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
     ValueError: invalid literal for int() with base 10: '123\xe1\x18\x7f'

I backported the modification to PyNumber_Int and PyNumber_Long, using 
PyString_FromStringAndSize and PyString_AS_STRING. It works as expected:

    Python 2.7.10+ (2.7:5d88c1d413b9+, Nov 20 2015, 04:58:55) 
    [GCC 4.8.4] on linux2
    Type "help", "copyright", "credits" or "license" for more 
    information.
    >>> int(buffer('123test', 1, 2))
    23
    [41951 refs]
    >>> long(buffer('123test', 1, 2))
    23L
    [41952 refs]

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25678>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to