summaryrefslogtreecommitdiffstats
path: root/Modules/mmapmodule.c
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-02-28 10:56:50 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-02-28 10:56:50 (GMT)
commit39c6dea4a24a1739971b0a68e0bdc49f68356b73 (patch)
treecfc3da838ab166cb1953967c359fd5a5adbb73dd /Modules/mmapmodule.c
parentf072122c79955e0e7695eb3f104bbd5d32132159 (diff)
downloadcpython-39c6dea4a24a1739971b0a68e0bdc49f68356b73.zip
cpython-39c6dea4a24a1739971b0a68e0bdc49f68356b73.tar.gz
cpython-39c6dea4a24a1739971b0a68e0bdc49f68356b73.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/mmapmodule.c')
-rw-r--r--Modules/mmapmodule.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 7fa1037..db94406 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -376,10 +376,17 @@ mmap_write_byte_method(mmap_object *self,
if (!is_writable(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 *