summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-pillow/0001-Handle-case-where-path-count-is-zero.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-pillow/0001-Handle-case-where-path-count-is-zero.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-pillow/0001-Handle-case-where-path-count-is-zero.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-pillow/0001-Handle-case-where-path-count-is-zero.patch b/meta-python/recipes-devtools/python/python3-pillow/0001-Handle-case-where-path-count-is-zero.patch
new file mode 100644
index 000000000..4c4f3d51f
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-pillow/0001-Handle-case-where-path-count-is-zero.patch
@@ -0,0 +1,77 @@
1From c48271ab354db49cdbd740bc45e13be4f0f7993c Mon Sep 17 00:00:00 2001
2From: Andrew Murray <radarhere@users.noreply.github.com>
3Date: Mon, 6 Dec 2021 22:25:14 +1100
4Subject: [PATCH] Handle case where path count is zero
5
6CVE: CVE-2022-22816
7
8Upstream-Status: Backport
9(https://github.com/python-pillow/Pillow/pull/5920/commits/c48271ab354db49cdbd740bc45e13be4f0f7993c)
10
11Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com>
12
13---
14 Tests/test_imagepath.py | 1 +
15 src/path.c | 33 +++++++++++++++++++--------------
16 2 files changed, 20 insertions(+), 14 deletions(-)
17
18diff --git a/Tests/test_imagepath.py b/Tests/test_imagepath.py
19index cd850bb1..b18271cc 100644
20--- a/Tests/test_imagepath.py
21+++ b/Tests/test_imagepath.py
22@@ -90,6 +90,7 @@ def test_path_odd_number_of_coordinates():
23 [
24 ([0, 1, 2, 3], (0.0, 1.0, 2.0, 3.0)),
25 ([3, 2, 1, 0], (1.0, 0.0, 3.0, 2.0)),
26+ (0, (0.0, 0.0, 0.0, 0.0)),
27 (1, (0.0, 0.0, 0.0, 0.0)),
28 ],
29 )
30diff --git a/src/path.c b/src/path.c
31index 64c767cb..dea274ee 100644
32--- a/src/path.c
33+++ b/src/path.c
34@@ -327,21 +327,26 @@ path_getbbox(PyPathObject *self, PyObject *args) {
35
36 xy = self->xy;
37
38- x0 = x1 = xy[0];
39- y0 = y1 = xy[1];
40+ if (self->count == 0) {
41+ x0 = x1 = 0;
42+ y0 = y1 = 0;
43+ } else {
44+ x0 = x1 = xy[0];
45+ y0 = y1 = xy[1];
46
47- for (i = 1; i < self->count; i++) {
48- if (xy[i + i] < x0) {
49- x0 = xy[i + i];
50- }
51- if (xy[i + i] > x1) {
52- x1 = xy[i + i];
53- }
54- if (xy[i + i + 1] < y0) {
55- y0 = xy[i + i + 1];
56- }
57- if (xy[i + i + 1] > y1) {
58- y1 = xy[i + i + 1];
59+ for (i = 1; i < self->count; i++) {
60+ if (xy[i + i] < x0) {
61+ x0 = xy[i + i];
62+ }
63+ if (xy[i + i] > x1) {
64+ x1 = xy[i + i];
65+ }
66+ if (xy[i + i + 1] < y0) {
67+ y0 = xy[i + i + 1];
68+ }
69+ if (xy[i + i + 1] > y1) {
70+ y1 = xy[i + i + 1];
71+ }
72 }
73 }
74
75--
762.33.0
77