[Python-checkins] r62235 - in python/trunk: Lib/test/test_zlib.py Modules/zlibmodule.c
gregory.p.smith
python-checkins at python.org
Wed Apr 9 02:25:17 CEST 2008
Author: gregory.p.smith
Date: Wed Apr 9 02:25:17 2008
New Revision: 62235
Modified:
python/trunk/Lib/test/test_zlib.py
python/trunk/Modules/zlibmodule.c
Log:
Fix zlib crash from zlib.decompressobj().flush(val) when val was not positive.
It tried to allocate negative or zero memory. That fails.
Modified: python/trunk/Lib/test/test_zlib.py
==============================================================================
--- python/trunk/Lib/test/test_zlib.py (original)
+++ python/trunk/Lib/test/test_zlib.py Wed Apr 9 02:25:17 2008
@@ -83,6 +83,11 @@
# verify failure on building decompress object with bad params
self.assertRaises(ValueError, zlib.decompressobj, 0)
+ def test_decompressobj_badflush(self):
+ # verify failure on calling decompressobj.flush with bad params
+ self.assertRaises(ValueError, zlib.decompressobj().flush, 0)
+ self.assertRaises(ValueError, zlib.decompressobj().flush, -1)
+
class CompressTestCase(unittest.TestCase):
Modified: python/trunk/Modules/zlibmodule.c
==============================================================================
--- python/trunk/Modules/zlibmodule.c (original)
+++ python/trunk/Modules/zlibmodule.c Wed Apr 9 02:25:17 2008
@@ -774,6 +774,10 @@
if (!PyArg_ParseTuple(args, "|i:flush", &length))
return NULL;
+ if (length <= 0) {
+ PyErr_SetString(PyExc_ValueError, "length must be greater than zero");
+ return NULL;
+ }
if (!(retval = PyString_FromStringAndSize(NULL, length)))
return NULL;
More information about the Python-checkins
mailing list