summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-02-28 11:39:45 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-02-28 11:39:45 (GMT)
commite363fa020b1775879f16bac99e2eb5f1d42f8fd3 (patch)
tree04c4e02e0a7ea14ccd87253e5b2dbc0f47d21fa5 /Modules
parentbebfd256ee039c21e895dd6d496b4ea0416a5c83 (diff)
downloadcpython-e363fa020b1775879f16bac99e2eb5f1d42f8fd3.zip
cpython-e363fa020b1775879f16bac99e2eb5f1d42f8fd3.tar.gz
cpython-e363fa020b1775879f16bac99e2eb5f1d42f8fd3.tar.bz2
Merged revisions 70052 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r70052 | hirokazu.yamamoto | 2009-02-28 19:31:54 +0900 | 2 lines Issue #5386: mmap.write_byte didn't check map size, so it could cause buffer overrun. ........
Diffstat (limited to 'Modules')
-rw-r--r--Modules/mmapmodule.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index fad60d1..8407c11 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -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 *