Issue #5386: mmap.write_byte didn't check map size, so it could cause buffer

overrun.
This commit is contained in:
Hirokazu Yamamoto 2009-02-28 10:31:54 +00:00
parent 7334735ee1
commit f2dc885780
3 changed files with 46 additions and 4 deletions

View file

@ -365,10 +365,17 @@ mmap_write_byte_method(mmap_object *self,
if (!is_writeable(self))
return NULL;
*(self->data+self->pos) = value;
self->pos += 1;
Py_INCREF(Py_None);
return Py_None;
if (self->pos < self->size) {
*(self->data+self->pos) = value;
self->pos += 1;
Py_INCREF(Py_None);
return Py_None;
}
else {
PyErr_SetString(PyExc_ValueError, "write byte out of range");
return NULL;
}
}
static PyObject *