Skip to content

[3.9] gh-95778: CVE-2020-10735: Prevent DoS by very large int() #96502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make the doctest actually run & fix it.
  • Loading branch information
gpshead committed Sep 1, 2022
commit 1378bdeb8a41dafe35c227fa84fbc1a5616faf7c
4 changes: 3 additions & 1 deletion Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5277,6 +5277,8 @@ and the sign are not counted towards the limit.

When an operation would exceed the limit, a :exc:`ValueError` is raised::

.. doctest::

>>> import sys
>>> sys.set_int_max_str_digits(4300) # Illustrative, this is the default.
>>> _ = int('2' * 5432)
Expand All @@ -5293,7 +5295,7 @@ When an operation would exceed the limit, a :exc:`ValueError` is raised::
ValueError: Exceeds the limit (4300) for integer string conversion: value has 8599 digits.
>>> len(hex(i_squared))
7144
>>> assert int(hex(i_squared), base=16) == i # Hexidecimal is unlimited.
>>> assert int(hex(i_squared), base=16) == i*i # Hexidecimal is unlimited.

The default limit is 4300 digits as provided in
:data:`sys.int_info.default_max_str_digits <sys.int_info>`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ line flag, or :mod:`sys` APIs. See the :ref:`integer string conversion length
limitation <int_max_str_digits>` documentation. The default limit is 4300
digits in string form.

Patch by Gregory P. Smith [Google] and Christian Heimes [Red Hat] with feedback from
Victor Stinner, Thomas Wouters, and Steve Dower.
Patch by Gregory P. Smith [Google] and Christian Heimes [Red Hat] with feedback
from Victor Stinner, Thomas Wouters, Steve Dower, and Ned Deily.