mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #5386: mmap.write_byte didn't check map size, so it could cause buffer
overrun.
This commit is contained in:
parent
7334735ee1
commit
f2dc885780
3 changed files with 46 additions and 4 deletions
|
|
@ -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 *
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue