Skip to content

Commit bd7299b

Browse files
author
amaury.forgeotdarc
committed
#4317: Fix an Array Bounds Read in imageop.rgb2rgb8.
Will backport to 2.4. git-svn-id: http://svn.python.org/projects/python/trunk@67266 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 763069a commit bd7299b

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Lib/test/test_imageop.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
_VALUES = (1, 2, 2**10, 2**15-1, 2**15, 2**15+1, 2**31-2, 2**31-1)
1616
VALUES = tuple( -x for x in reversed(_VALUES) ) + (0,) + _VALUES
1717
AAAAA = "A" * 1024
18+
MAX_LEN = 2**20
1819

1920

2021
class InputValidationTests(unittest.TestCase):
@@ -26,7 +27,7 @@ def _check(self, name, size=None, *extra):
2627
strlen = abs(width * height)
2728
if size:
2829
strlen *= size
29-
if strlen < 1024:
30+
if strlen < MAX_LEN:
3031
data = "A" * strlen
3132
else:
3233
data = AAAAA

Misc/NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 1
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #4317: Fixed a crash in the imageop.rgb2rgb8() function.
16+
1517
- Issue #4230: If ``__getattr__`` is a descriptor, it now functions correctly.
1618

1719
- Issue #4048: The parser module now correctly validates relative imports.

Modules/imageop.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ imageop_rgb2rgb8(PyObject *self, PyObject *args)
590590
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
591591
return 0;
592592

593-
if ( !check_multiply_size(len*4, x, "x", y, "y", 4) )
593+
if ( !check_multiply_size(len, x, "x", y, "y", 4) )
594594
return 0;
595595
nlen = x*y;
596596
if ( !check_multiply(nlen, x, y) )

0 commit comments

Comments
 (0)