[Python-checkins] r69945 - sandbox/trunk/mmap/Modules/mmapmodule.c

hirokazu.yamamoto python-checkins at python.org
Tue Feb 24 21:31:42 CET 2009


Author: hirokazu.yamamoto
Date: Tue Feb 24 21:31:42 2009
New Revision: 69945
Log:
mmap.write_byte didn't check buffer size.
import mmap
m = mmap.mmap(-1, 1)
for i in xrange(10000): # enough?
 print i
 m.write_byte('1') # crash
Modified:
 sandbox/trunk/mmap/Modules/mmapmodule.c
Modified: sandbox/trunk/mmap/Modules/mmapmodule.c
==============================================================================
--- sandbox/trunk/mmap/Modules/mmapmodule.c	(original)
+++ sandbox/trunk/mmap/Modules/mmapmodule.c	Tue Feb 24 21:31:42 2009
@@ -365,6 +365,11 @@
 
 	if (!is_writeable(self))
 		return NULL;
+
+	if (self->pos >= self->size) {
+		PyErr_SetString(PyExc_ValueError, "data out of range");
+		return NULL;
+	}
 	*(self->data+self->pos) = value;
 	self->pos += 1;
 	Py_INCREF(Py_None);


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /