10000 [3.8] bpo-39068: Fix race condition in base64 (GH-17627) by serhiy-storchaka · Pull Request #24022 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.8] bpo-39068: Fix race condition in base64 (GH-17627) #24022

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 2 commits into from
Jan 1, 2021
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
Next Next commit
[3.8] bpo-39068: Fix race condition in base64 (GH-17627)
There was a race condition in base64 in lazy initialization of multiple globals..
(cherry picked from commit 9655434)

Co-authored-by: Brandon Stansbury <brandonrstansbury@gmail.com>
  • Loading branch information
drmonkeysee authored and serhiy-storchaka committed Dec 31, 2020
commit 614cd80e2a17b81ae9e498a30929b0df4775af9e
4 changes: 2 additions & 2 deletions Lib/base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False):
global _a85chars, _a85chars2
# Delay the initialization of tables to not waste memory
# if the function is never called
if _a85chars is None:
if _a85chars2 is None:
_a85chars = [bytes((i,)) for i in range(33, 118)]
_a85chars2 = [(a + b) for a in _a85chars for b in _a85chars]

Expand Down Expand Up @@ -428,7 +428,7 @@ def b85encode(b, pad=False):
global _b85chars, _b85chars2
# Delay the initialization of tables to not waste memory
# if the function is never called
if _b85chars is None:
if _b85chars2 is None:
_b85chars = [bytes((i,)) for i in _b85alphabet]
_b85chars2 = [(a + b) for a in _b85chars for b in _b85chars]
return _85encode(b, _b85chars, _b85chars2, pad)
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,7 @@ Tage Stabell-Kulo
Quentin Stafford-Fraser
Frank Stajano
Joel Stanley
Brandon Stansbury
Anthony Starks
David Steele
Oliver Steele
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix initialization race condition in :func:`a85encode` and :func:`b85encode`
in :mod:`base64`. Patch by Brandon Stansbury.
0