Navigation Menu

Skip to content
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

base64.b32decode() leads into UnboundLocalError and OverflowError on some data #78345

Closed
Barro mannequin opened this issue Jul 20, 2018 · 6 comments
Closed

base64.b32decode() leads into UnboundLocalError and OverflowError on some data #78345

Barro mannequin opened this issue Jul 20, 2018 · 6 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Barro
Copy link
Mannequin

Barro mannequin commented Jul 20, 2018

BPO 34164
Nosy @serhiy-storchaka, @Barro
PRs
  • bpo-34164: Fix handling of incorrect padding in base64.b32decode(). #8351
  • [3.7] bpo-34164: Fix handling of incorrect padding in base64.b32decode(). (GH-8351) #8435
  • [3.6] bpo-34164: Fix handling of incorrect padding in base64.b32decode(). (GH-8351) #8436
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-07-24.12:12:19.397>
    created_at = <Date 2018-07-20.09:21:09.721>
    labels = ['3.7', '3.8', 'type-bug', 'library']
    title = 'base64.b32decode() leads into UnboundLocalError and OverflowError on some data'
    updated_at = <Date 2018-07-24.12:12:19.396>
    user = 'https://github.com/Barro'

    bugs.python.org fields:

    activity = <Date 2018-07-24.12:12:19.396>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-07-24.12:12:19.397>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2018-07-20.09:21:09.721>
    creator = 'Barro'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34164
    keywords = ['patch']
    message_count = 6.0
    messages = ['321991', '321992', '322012', '322284', '322289', '322294']
    nosy_count = 2.0
    nosy_names = ['serhiy.storchaka', 'Barro']
    pr_nums = ['8351', '8435', '8436']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue34164'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @Barro
    Copy link
    Mannequin Author

    Barro mannequin commented Jul 20, 2018

    base64.b32decode() function leads into "UnboundLocalError: local variable 'acc' referenced before assignment" when passing 8 equality signs as data:

    >>> import base64
    >>> base64.b32decode(b"========")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/tmp/python-3.7-bin/lib/python3.7/base64.py", line 235, in b32decode
        acc <<= 5 * padchars
    UnboundLocalError: local variable 'acc' referenced before assignment

    When passing a different number of equality signs, the documented binascii.Error exception is thrown.

    @Barro Barro mannequin added type-crash A hard crash of the interpreter, possibly with a core dump 3.7 (EOL) end of life stdlib Python modules in the Lib dir labels Jul 20, 2018
    @Barro
    Copy link
    Mannequin Author

    Barro mannequin commented Jul 20, 2018

    Apparently base64.b32decode() also has another issue that I missed when going through the issues with base64 module:

    >>> import base64
    >>> base64.b32decode(b"M===============================")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/tmp/python-3.7-bin/lib/python3.7/base64.py", line 236, in b32decode
        last = acc.to_bytes(5, 'big')
    OverflowError: int too big to convert

    @Barro Barro mannequin changed the title base64.b32decode() leads into UnboundLocalError on some data base64.b32decode() leads into UnboundLocalError and OverflowError on some data Jul 20, 2018
    @serhiy-storchaka
    Copy link
    Member

    Thank you for your report Jussi.

    The type "crash" is used for hard crashes of the Python interpreter – possibly with a core dump or a Windows error box.

    @serhiy-storchaka serhiy-storchaka added 3.8 only security fixes type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Jul 20, 2018
    @serhiy-storchaka
    Copy link
    Member

    New changeset ac0b3c2 by Serhiy Storchaka in branch 'master':
    bpo-34164: Fix handling of incorrect padding in base64.b32decode(). (GH-8351)
    ac0b3c2

    @serhiy-storchaka
    Copy link
    Member

    New changeset 0b27169 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.7':
    bpo-34164: Fix handling of incorrect padding in base64.b32decode(). (GH-8351) (GH-8435)
    0b27169

    @serhiy-storchaka
    Copy link
    Member

    New changeset 113f86e by Serhiy Storchaka in branch '3.6':
    [3.6] bpo-34164: Fix handling of incorrect padding in base64.b32decode(). (GH-8351) (GH-8436)
    113f86e

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant