From: Michael W. Hudson Date: Mon, 31 Jan 2005 17:01:59 +0000 (+0000) Subject: Fix X-Git-Tag: v2.5a0~2069 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9867ced6c2ba0a47a3d6fa54fdcc0d3a7d31597b;p=thirdparty%2FPython%2Fcpython.git Fix [ 1077106 ] Negative numbers to os.read() cause segfault Sorry for sitting on this for so long! Is there a chance it could make 2.3.5? --- diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 7ecd8646c397..2d3eaa39cb54 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5349,6 +5349,10 @@ posix_read(PyObject *self, PyObject *args) PyObject *buffer; if (!PyArg_ParseTuple(args, "ii:read", &fd, &size)) return NULL; + if (size < 0) { + errno = EINVAL; + return posix_error(); + } buffer = PyString_FromStringAndSize((char *)NULL, size); if (buffer == NULL) return NULL;