Visitar URL original
[3.8] gh-95778: CVE-2020-10735: Prevent DoS by very large int() by gpshead · Pull Request #96503 · python/cpython · GitHub
Skip to content
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 70b9aefc09252c33709de425c4f0837d70cd0286
4 changes: 3 additions & 1 deletion Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4903,6 +4903,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 @@ -4919,7 +4921,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.