diff options
| author | Michael Manfre <mike@manfre.net> | 2024-12-11 21:39:32 -0500 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2025-01-14 08:44:20 -0300 |
| commit | 4806731e58f3e8700a3c802e77899d54ac6021fe (patch) | |
| tree | 1d6929d45578e2d1f44c5aed80fc584a2359a360 /django/db/models/fields | |
| parent | d6749de9278c5417944a0d8e22967b4986906b1c (diff) | |
[5.1.x] Fixed CVE-2024-56374 -- Mitigated potential DoS in IPv6 validation.
Thanks Saravana Kumar for the report, and Sarah Boyce and Mariusz
Felisiak for the reviews.
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
Diffstat (limited to 'django/db/models/fields')
| -rw-r--r-- | django/db/models/fields/__init__.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index d1f31f0211..76b46a3deb 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -32,7 +32,7 @@ from django.utils.dateparse import ( ) from django.utils.duration import duration_microseconds, duration_string from django.utils.functional import Promise, cached_property -from django.utils.ipv6 import clean_ipv6_address +from django.utils.ipv6 import MAX_IPV6_ADDRESS_LENGTH, clean_ipv6_address from django.utils.text import capfirst from django.utils.translation import gettext_lazy as _ @@ -2228,7 +2228,7 @@ class GenericIPAddressField(Field): self.default_validators = validators.ip_address_validators( protocol, unpack_ipv4 ) - kwargs["max_length"] = 39 + kwargs["max_length"] = MAX_IPV6_ADDRESS_LENGTH super().__init__(verbose_name, name, *args, **kwargs) def check(self, **kwargs): @@ -2255,7 +2255,7 @@ class GenericIPAddressField(Field): kwargs["unpack_ipv4"] = self.unpack_ipv4 if self.protocol != "both": kwargs["protocol"] = self.protocol - if kwargs.get("max_length") == 39: + if kwargs.get("max_length") == self.max_length: del kwargs["max_length"] return name, path, args, kwargs |
