diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-08-12 14:49:50 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-08-12 14:49:50 (GMT) |
commit | f91d46a17d85da323895950852093117bc21f860 (patch) | |
tree | c6a3e68cf22a6a102f9c1dc780438f0307b6588f /Modules/posixmodule.c | |
parent | aa8efbf08469c3667ed22362c0e10b83ae124c0b (diff) | |
download | cpython-f91d46a17d85da323895950852093117bc21f860.zip cpython-f91d46a17d85da323895950852093117bc21f860.tar.gz cpython-f91d46a17d85da323895950852093117bc21f860.tar.bz2 |
Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
by denying s# to parse objects that have a releasebuffer procedure,
and introducing s*.
More module might need to get converted to use s*.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index f18e154..8104ccd 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -6334,15 +6334,16 @@ Write a string to a file descriptor."); static PyObject * posix_write(PyObject *self, PyObject *args) { + Py_buffer pbuf; int fd; Py_ssize_t size; - char *buffer; - if (!PyArg_ParseTuple(args, "is#:write", &fd, &buffer, &size)) + if (!PyArg_ParseTuple(args, "is*:write", &fd, &pbuf)) return NULL; Py_BEGIN_ALLOW_THREADS - size = write(fd, buffer, (size_t)size); + size = write(fd, pbuf.buf, (size_t)pbuf.len); Py_END_ALLOW_THREADS + PyBuffer_Release(&pbuf); if (size < 0) return posix_error(); return PyInt_FromSsize_t(size); |