Incorrect signature for PyObject_AsCharBuffer
- Dominant language
- C
- Stars
- 4
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
```
Python 2.5 (and above) changed the signature of PyObject_AsCharBuffer to:
int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t
*buffer_len)
This matters on 64-bit systems, where Py_ssize_t is 64-bits, but int is
32-bits. The signature in event.pyx is:
int PyObject_AsCharBuffer(object obj, char **buffer, int *buffer_len)
This causes the 4-bytes on the stack beside *buffer_len to get clobbered,
leading to random crashes/corruption.
```
Original issue reported on code.google.com by `p...@dropbox.com` on 8 Jan 2013 at 5:35
Contributor guide
No contributing guide indexed for this repository
Research direction
The incorrect declaration is in event.pyx; start by reading the PyObject_AsCharBuffer declaration shown in the issue and compare its parameter types with the Python 2.5-and-above signature. Done means the declaration uses the const buffer pointer and Py_ssize_t length pointer so 64-bit calls no longer corrupt the stack.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100