<feed xmlns='http://www.w3.org/2005/Atom'>
<title>python.git/Lib/test/test_decimal.py, branch 3.8</title>
<subtitle>Python interpreter</subtitle>
<id>http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Lib/test/test_decimal.py?h=3.8</id>
<link rel='self' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Lib/test/test_decimal.py?h=3.8'/>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/'/>
<updated>2022-09-05T20:26:09Z</updated>
<entry>
<title>[3.8] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96503)</title>
<updated>2022-09-05T20:26:09Z</updated>
<author>
<name>Gregory P. Smith</name>
<email>greg@krypto.org</email>
</author>
<published>2022-09-05T20:26:09Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=b5e331fdb38684808ffc540d53e8595bdc408b89'/>
<id>urn:sha1:b5e331fdb38684808ffc540d53e8595bdc408b89</id>
<content type='text'>
* Correctly pre-check for int-to-str conversion

Converting a large enough `int` to a decimal string raises `ValueError` as expected. However, the raise comes _after_ the quadratic-time base-conversion algorithm has run to completion. For effective DOS prevention, we need some kind of check before entering the quadratic-time loop. Oops! =)

The quick fix: essentially we catch _most_ values that exceed the threshold up front. Those that slip through will still be on the small side (read: sufficiently fast), and will get caught by the existing check so that the limit remains exact.

The justification for the current check. The C code check is:
```c
max_str_digits / (3 * PyLong_SHIFT) &lt;= (size_a - 11) / 10
```

In GitHub markdown math-speak, writing $M$ for `max_str_digits`, $L$ for `PyLong_SHIFT` and $s$ for `size_a`, that check is:
$$\left\lfloor\frac{M}{3L}\right\rfloor \le \left\lfloor\frac{s - 11}{10}\right\rfloor$$

From this it follows that
$$\frac{M}{3L} &lt; \frac{s-1}{10}$$
hence that
$$\frac{L(s-1)}{M} &gt; \frac{10}{3} &gt; \log_2(10).$$
So
$$2^{L(s-1)} &gt; 10^M.$$
But our input integer $a$ satisfies $|a| \ge 2^{L(s-1)}$, so $|a|$ is larger than $10^M$. This shows that we don't accidentally capture anything _below_ the intended limit in the check.

&lt;!-- gh-issue-number: gh-95778 --&gt;
* Issue: gh-95778
&lt;!-- /gh-issue-number --&gt;

Co-authored-by: Gregory P. Smith [Google LLC] &lt;greg@krypto.org&gt;
Co-authored-by: Christian Heimes &lt;christian@python.org&gt;
Co-authored-by: Mark Dickinson &lt;dickinsm@gmail.com&gt;</content>
</entry>
<entry>
<title>[3.8] Revert bpo-39576: Prevent memory error for overly optimistic precisions (GH-20747)</title>
<updated>2020-06-08T23:57:11Z</updated>
<author>
<name>Stefan Krah</name>
<email>skrah@bytereef.org</email>
</author>
<published>2020-06-08T23:57:11Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=0f5a28f834bdac2da8a04597dc0fc5b71e50da9d'/>
<id>urn:sha1:0f5a28f834bdac2da8a04597dc0fc5b71e50da9d</id>
<content type='text'>
This reverts commit b6271025c640c228505dc9f194362a0c2ab81c61.</content>
</entry>
<entry>
<title>bpo-39576: Prevent memory error for overly optimistic precisions (GH-18581) (#18584)</title>
<updated>2020-02-21T01:16:42Z</updated>
<author>
<name>Miss Islington (bot)</name>
<email>31488909+miss-islington@users.noreply.github.com</email>
</author>
<published>2020-02-21T01:16:42Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=b6271025c640c228505dc9f194362a0c2ab81c61'/>
<id>urn:sha1:b6271025c640c228505dc9f194362a0c2ab81c61</id>
<content type='text'>
(cherry picked from commit 90930e65455f60216f09d175586139242dbba260)

Authored-by: Stefan Krah &lt;skrah@bytereef.org&gt;</content>
</entry>
<entry>
<title>bpo-35133: Fix mistakes when concatenate string literals on different lines. (GH-10284)</title>
<updated>2018-11-05T14:20:25Z</updated>
<author>
<name>Serhiy Storchaka</name>
<email>storchaka@gmail.com</email>
</author>
<published>2018-11-05T14:20:25Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=34fd4c20198dea6ab2fe8dc6d32d744d9bde868d'/>
<id>urn:sha1:34fd4c20198dea6ab2fe8dc6d32d744d9bde868d</id>
<content type='text'>
Two kind of mistakes:

1. Missed space. After concatenating there is no space between words.

2. Missed comma. Causes unintentional concatenating in a list of strings.
</content>
</entry>
<entry>
<title>bpo-33750: Reset thread-local context precision in test_round(). (#7355)</title>
<updated>2018-06-03T16:40:00Z</updated>
<author>
<name>Stefan Krah</name>
<email>skrah@bytereef.org</email>
</author>
<published>2018-06-03T16:40:00Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=e95dfc5006d19e59c7871faa9973356844ddb3ae'/>
<id>urn:sha1:e95dfc5006d19e59c7871faa9973356844ddb3ae</id>
<content type='text'>
</content>
</entry>
<entry>
<title>bpo-31234: Join threads in tests (#3572)</title>
<updated>2017-09-14T15:43:04Z</updated>
<author>
<name>Victor Stinner</name>
<email>victor.stinner@gmail.com</email>
</author>
<published>2017-09-14T15:43:04Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=18e95b4176256f100429a806d0455406df98f984'/>
<id>urn:sha1:18e95b4176256f100429a806d0455406df98f984</id>
<content type='text'>
Call thread.join() on threads to prevent the "dangling threads"
warning.</content>
</entry>
<entry>
<title>bpo-31370: Remove support for threads-less builds (#3385)</title>
<updated>2017-09-07T16:56:24Z</updated>
<author>
<name>Antoine Pitrou</name>
<email>pitrou@free.fr</email>
</author>
<published>2017-09-07T16:56:24Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=a6a4dc816d68df04a7d592e0b6af8c7ecc4d4344'/>
<id>urn:sha1:a6a4dc816d68df04a7d592e0b6af8c7ecc4d4344</id>
<content type='text'>
* Remove Setup.config
* Always define WITH_THREAD for compatibility.

</content>
</entry>
<entry>
<title>bpo-29919: Remove unused imports found by pyflakes (#137)</title>
<updated>2017-03-27T14:05:26Z</updated>
<author>
<name>Victor Stinner</name>
<email>victor.stinner@gmail.com</email>
</author>
<published>2017-03-27T14:05:26Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=d6debb24e06152a827769b0cac24c47deccdeac1'/>
<id>urn:sha1:d6debb24e06152a827769b0cac24c47deccdeac1</id>
<content type='text'>
Make also minor PEP8 coding style fixes on modified imports.</content>
</entry>
<entry>
<title>Fixed #29534 - _decimal difference with _pydecimal (#65)</title>
<updated>2017-02-14T18:22:55Z</updated>
<author>
<name>Andrew Nester</name>
<email>andrew.nester.dev@gmail.com</email>
</author>
<published>2017-02-14T18:22:55Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=6d1dece06d13a7d40637e07b2c79f34aab368766'/>
<id>urn:sha1:6d1dece06d13a7d40637e07b2c79f34aab368766</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Remove unused imports.</title>
<updated>2016-12-16T18:00:15Z</updated>
<author>
<name>Serhiy Storchaka</name>
<email>storchaka@gmail.com</email>
</author>
<published>2016-12-16T18:00:15Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=70d28a184c42d107cc8c69a95aa52a4469e7929c'/>
<id>urn:sha1:70d28a184c42d107cc8c69a95aa52a4469e7929c</id>
<content type='text'>
</content>
</entry>
</feed>
