diff options
| author | Soumya Sambu <soumya.sambu@windriver.com> | 2025-01-10 13:17:57 +0000 |
|---|---|---|
| committer | Armin Kuster <akuster808@gmail.com> | 2025-01-22 19:20:15 -0500 |
| commit | 46701493ac4201c76aad1aeaf28e9b35851398ec (patch) | |
| tree | 7d5cb5fc2f251532dcf64dc492e83a74963ecf7e /meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0002.patch | |
| parent | 91d60c9b0aafc368acdc034cc5f86fdf7d0a3343 (diff) | |
| download | meta-openembedded-46701493ac4201c76aad1aeaf28e9b35851398ec.tar.gz | |
python3-django: Fix CVE-2024-41989
An issue was discovered in Django 5.0 before 5.0.8 and 4.2 before 4.2.15. The
floatformat template filter is subject to significant memory consumption when
given a string representation of a number in scientific notation with a large
exponent.
Reference:
https://nvd.nist.gov/vuln/detail/CVE-2024-41989
Upstream-patches:
https://github.com/django/django/commit/08c5a787262c1ae57f6517d4574b54a5fcaad124
https://github.com/django/django/commit/4b066bde692078b194709d517b27e55defae787c
https://github.com/django/django/commit/dcd974698301a38081c141ccba6dcafa5ed2c80e
https://github.com/django/django/commit/fc76660f589ac07e45e9cd34ccb8087aeb11904b
Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0002.patch')
| -rw-r--r-- | meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0002.patch | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0002.patch b/meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0002.patch new file mode 100644 index 0000000000..51cf79ffbd --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-django/CVE-2024-41989-0002.patch | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | From 4b066bde692078b194709d517b27e55defae787c Mon Sep 17 00:00:00 2001 | ||
| 2 | From: David Wobrock <david.wobrock@gmail.com> | ||
| 3 | Date: Wed, 18 Jan 2023 22:54:17 +0100 | ||
| 4 | Subject: [PATCH] Fixed #34272 -- Fixed floatformat crash on zero with trailing | ||
| 5 | zeros to zero decimal places. | ||
| 6 | |||
| 7 | Regression in 08c5a787262c1ae57f6517d4574b54a5fcaad124. | ||
| 8 | |||
| 9 | Thanks Andrii Lahuta for the report. | ||
| 10 | |||
| 11 | CVE: CVE-2024-41989 | ||
| 12 | |||
| 13 | Upstream-Status: Backport [https://github.com/django/django/commit/4b066bde692078b194709d517b27e55defae787c] | ||
| 14 | |||
| 15 | Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com> | ||
| 16 | --- | ||
| 17 | django/template/defaultfilters.py | 2 +- | ||
| 18 | tests/template_tests/filter_tests/test_floatformat.py | 2 ++ | ||
| 19 | 2 files changed, 3 insertions(+), 1 deletion(-) | ||
| 20 | |||
| 21 | diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py | ||
| 22 | index 9ca530c..e72593b 100644 | ||
| 23 | --- a/django/template/defaultfilters.py | ||
| 24 | +++ b/django/template/defaultfilters.py | ||
| 25 | @@ -140,7 +140,7 @@ def floatformat(text, arg=-1): | ||
| 26 | except (ValueError, OverflowError, InvalidOperation): | ||
| 27 | return input_val | ||
| 28 | |||
| 29 | - if not m and p < 0: | ||
| 30 | + if not m and p <= 0: | ||
| 31 | return mark_safe(formats.number_format('%d' % (int(d)), 0)) | ||
| 32 | |||
| 33 | exp = Decimal(1).scaleb(-abs(p)) | ||
| 34 | diff --git a/tests/template_tests/filter_tests/test_floatformat.py b/tests/template_tests/filter_tests/test_floatformat.py | ||
| 35 | index acad66d..538f501 100644 | ||
| 36 | --- a/tests/template_tests/filter_tests/test_floatformat.py | ||
| 37 | +++ b/tests/template_tests/filter_tests/test_floatformat.py | ||
| 38 | @@ -65,6 +65,8 @@ class FunctionTests(SimpleTestCase): | ||
| 39 | self.assertEqual(floatformat(0, 7), '0.0000000') | ||
| 40 | self.assertEqual(floatformat(0, 10), '0.0000000000') | ||
| 41 | self.assertEqual(floatformat(0.000000000000000000015, 20), '0.00000000000000000002') | ||
| 42 | + self.assertEqual(floatformat("0.00", 0), "0") | ||
| 43 | + self.assertEqual(floatformat(Decimal("0.00"), 0), "0") | ||
| 44 | |||
| 45 | def test_infinity(self): | ||
| 46 | pos_inf = float(1e30000) | ||
| 47 | -- | ||
| 48 | 2.40.0 | ||
