Skip to content

Commit a5f3ceb

Browse files
committed
python#4317: Fix an Array Bounds Read in imageop.rgb2rgb8.
Backport of r67266
1 parent 900fb20 commit a5f3ceb

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
@@ -13,6 +13,7 @@
1313
_VALUES = (1, 2, 2**10, 2**15-1, 2**15, 2**15+1, 2**31-2, 2**31-1)
1414
VALUES = tuple( -x for x in reversed(_VALUES) ) + (0,) + _VALUES
1515
AAAAA = "A" * 1024
16+
MAX_LEN = 2**20
1617

1718

1819
class InputValidationTests(unittest.TestCase):
@@ -24,7 +25,7 @@ def _check(self, name, size=None, *extra):
2425
strlen = abs(width * height)
2526
if size:
2627
strlen *= size
27-
if strlen < 1024:
28+
if strlen < MAX_LEN:
2829
data = "A" * strlen
2930
else:
3031
data = AAAAA

Misc/NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ What's New in Python 2.4.6c1?
1212
Core and builtins
1313
-----------------
1414

15+
- Issue #4317: Fixed a crash in the imageop.rgb2rgb8() function.
16+
1517
- Issue #4230: Fix a crash when a class has a custom __getattr__ and an
1618
__getattribute__ method that deletes the __getattr__ attribute.
1719

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)