]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#4317: Fix an Array Bounds Read in imageop.rgb2rgb8.
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 18 Nov 2008 22:19:37 +0000 (22:19 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 18 Nov 2008 22:19:37 +0000 (22:19 +0000)
Will backport to 2.4.

Lib/test/test_imageop.py
Misc/NEWS
Modules/imageop.c

index 6deaa348cb845aca801f38d84af91358b20ad9b1..9063b22090e3350358ad293884265ca77f5e3fd2 100755 (executable)
@@ -15,6 +15,7 @@ SIZES = (1, 2, 3, 4)
 _VALUES = (1, 2, 2**10, 2**15-1, 2**15, 2**15+1, 2**31-2, 2**31-1)
 VALUES = tuple( -x for x in reversed(_VALUES) ) + (0,) + _VALUES
 AAAAA = "A" * 1024
+MAX_LEN = 2**20
 
 
 class InputValidationTests(unittest.TestCase):
@@ -26,7 +27,7 @@ class InputValidationTests(unittest.TestCase):
                 strlen = abs(width * height)
                 if size:
                     strlen *= size
-                if strlen < 1024:
+                if strlen < MAX_LEN:
                     data = "A" * strlen
                 else:
                     data = AAAAA
index 10125416d0bda22f5e5d9f00e3f6bbe52bf26932..d84ec8494e23ce980567e29e92598b647cd395e5 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 1
 Core and Builtins
 -----------------
 
+- Issue #4317: Fixed a crash in the imageop.rgb2rgb8() function.
+
 - Issue #4230: If ``__getattr__`` is a descriptor, it now functions correctly.
 
 - Issue #4048: The parser module now correctly validates relative imports.
index 61a0c2f813775f7c358444abebe92384c0bb4119..8d0d68f71dc2f2878e7aca5dc04f3f7f370926c3 100644 (file)
@@ -590,7 +590,7 @@ imageop_rgb2rgb8(PyObject *self, PyObject *args)
        if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
                return 0;
 
-       if ( !check_multiply_size(len*4, x, "x", y, "y", 4) )
+       if ( !check_multiply_size(len, x, "x", y, "y", 4) )
                return 0;
        nlen = x*y;
        if ( !check_multiply(nlen, x, y) )