]> granicus.if.org Git - python/commitdiff
Fix
authorMichael W. Hudson <mwh@python.net>
Mon, 31 Jan 2005 17:01:59 +0000 (17:01 +0000)
committerMichael W. Hudson <mwh@python.net>
Mon, 31 Jan 2005 17:01:59 +0000 (17:01 +0000)
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?

Modules/posixmodule.c

index 7ecd8646c397ff374f14b0366b88f283aad53213..2d3eaa39cb5419e5e8a4efeab2dabaa2a7f43bd3 100644 (file)
@@ -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;