summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch56
1 files changed, 56 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch b/meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch
new file mode 100644
index 0000000000..bbfc32a6c7
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-pillow/CVE-2023-50447-3.patch
@@ -0,0 +1,56 @@
1From 0ca3c33c59927e1c7e0c14dbc1eea1dfb2431a80
2From: Andrew Murray <radarhere@users.noreply.github.com>
3Date: Sat, 28 Oct 2023 15:58:52 +1100
4Subject: [PATCH] python3-pillow: Allow ops
5
6CVE: CVE-2023-50447
7
8Upstream-Status: Backport [https://github.com/python-pillow/Pillow/commit/0ca3c33c59927e1c7e0c14dbc1eea1dfb2431a80]
9
10Signed-off-by: Rahul Janani Pandi <RahulJanani.Pandi@windriver.com>
11---
12 Tests/test_imagemath.py | 5 +++++
13 src/PIL/ImageMath.py | 9 +++++----
14 2 files changed, 10 insertions(+), 4 deletions(-)
15
16diff --git a/Tests/test_imagemath.py b/Tests/test_imagemath.py
17index fe7ac9a7a..ded8c0011 100644
18--- a/Tests/test_imagemath.py
19+++ b/Tests/test_imagemath.py
20@@ -63,6 +63,11 @@ def test_prevent_exec(expression):
21 ImageMath.eval(expression)
22
23
24+def test_prevent_double_underscores():
25+ with pytest.raises(ValueError):
26+ ImageMath.eval("1", {"__": None})
27+
28+
29 def test_logical():
30 assert pixel(ImageMath.eval("not A", images)) == 0
31 assert pixel(ImageMath.eval("A and B", images)) == "L 2"
32diff --git a/src/PIL/ImageMath.py b/src/PIL/ImageMath.py
33index 923a8eeae..c14598a4c 100644
34--- a/src/PIL/ImageMath.py
35+++ b/src/PIL/ImageMath.py
36@@ -237,13 +237,14 @@ def eval(expression, _dict={}, **kw):
37
38 # build execution namespace
39 args = ops.copy()
40- args.update(_dict)
41- args.update(kw)
42- for k, v in args.items():
43- if '__' in k or hasattr(__builtins__, k):
44+ for k in list(_dict.keys()) + list(kw.keys()):
45+ if "__" in k or hasattr(__builtins__, k):
46 msg = f"'{k}' not allowed"
47 raise ValueError(msg)
48
49+ args.update(_dict)
50+ args.update(kw)
51+ for k, v in args.items():
52 if hasattr(v, "im"):
53 args[k] = _Operand(v)
54
55--
562.40.0