diff options
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.patch | 77 |
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 @@ | |||
1 | From c48271ab354db49cdbd740bc45e13be4f0f7993c Mon Sep 17 00:00:00 2001 | ||
2 | From: Andrew Murray <radarhere@users.noreply.github.com> | ||
3 | Date: Mon, 6 Dec 2021 22:25:14 +1100 | ||
4 | Subject: [PATCH] Handle case where path count is zero | ||
5 | |||
6 | CVE: CVE-2022-22816 | ||
7 | |||
8 | Upstream-Status: Backport | ||
9 | (https://github.com/python-pillow/Pillow/pull/5920/commits/c48271ab354db49cdbd740bc45e13be4f0f7993c) | ||
10 | |||
11 | Signed-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 | |||
18 | diff --git a/Tests/test_imagepath.py b/Tests/test_imagepath.py | ||
19 | index 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 | ) | ||
30 | diff --git a/src/path.c b/src/path.c | ||
31 | index 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 | -- | ||
76 | 2.33.0 | ||
77 | |||