summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0003.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0003.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0003.patch57
1 files changed, 57 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0003.patch b/meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0003.patch
new file mode 100644
index 0000000000..649a58f822
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0003.patch
@@ -0,0 +1,57 @@
1From dcd974698301a38081c141ccba6dcafa5ed2c80e Mon Sep 17 00:00:00 2001
2From: "Panagiotis H.M. Issaris" <takis@issaris.com>
3Date: Wed, 22 Feb 2023 20:46:16 +0100
4Subject: [PATCH] Fixed #34363 -- Fixed floatformat crash on zero with trailing
5 zeros.
6
7Regression in 08c5a787262c1ae57f6517d4574b54a5fcaad124.
8Follow up to 4b066bde692078b194709d517b27e55defae787c.
9
10CVE: CVE-2024-41989
11
12Upstream-Status: Backport [https://github.com/django/django/commit/dcd974698301a38081c141ccba6dcafa5ed2c80e]
13
14Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com>
15---
16 django/template/defaultfilters.py | 3 ++-
17 tests/template_tests/filter_tests/test_floatformat.py | 4 ++++
18 2 files changed, 6 insertions(+), 1 deletion(-)
19
20diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
21index e72593b..1aba321 100644
22--- a/django/template/defaultfilters.py
23+++ b/django/template/defaultfilters.py
24@@ -2,7 +2,7 @@
25 import random as random_module
26 import re
27 import types
28-from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation
29+from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation, getcontext
30 from functools import wraps
31 from operator import itemgetter
32 from pprint import pformat
33@@ -149,6 +149,7 @@ def floatformat(text, arg=-1):
34 units = len(tupl[1])
35 units += -tupl[2] if m else tupl[2]
36 prec = abs(p) + units + 1
37+ prec = max(getcontext().prec, prec)
38
39 # Avoid conversion to scientific notation by accessing `sign`, `digits`,
40 # and `exponent` from Decimal.as_tuple() directly.
41diff --git a/tests/template_tests/filter_tests/test_floatformat.py b/tests/template_tests/filter_tests/test_floatformat.py
42index 538f501..413ba4b 100644
43--- a/tests/template_tests/filter_tests/test_floatformat.py
44+++ b/tests/template_tests/filter_tests/test_floatformat.py
45@@ -67,6 +67,10 @@ class FunctionTests(SimpleTestCase):
46 self.assertEqual(floatformat(0.000000000000000000015, 20), '0.00000000000000000002')
47 self.assertEqual(floatformat("0.00", 0), "0")
48 self.assertEqual(floatformat(Decimal("0.00"), 0), "0")
49+ self.assertEqual(floatformat("0.0000", 2), "0.00")
50+ self.assertEqual(floatformat(Decimal("0.0000"), 2), "0.00")
51+ self.assertEqual(floatformat("0.000000", 4), "0.0000")
52+ self.assertEqual(floatformat(Decimal("0.000000"), 4), "0.0000")
53
54 def test_infinity(self):
55 pos_inf = float(1e30000)
56--
572.40.0