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

When xdrlib.Packer().pack_string() fails, the Packer is corrupted #67978

Closed
ostcar mannequin opened this issue Mar 27, 2015 · 4 comments
Closed

When xdrlib.Packer().pack_string() fails, the Packer is corrupted #67978

ostcar mannequin opened this issue Mar 27, 2015 · 4 comments
Labels
stdlib Python modules in the Lib dir

Comments

@ostcar
Copy link
Mannequin

ostcar mannequin commented Mar 27, 2015

BPO 23790
Nosy @bitdancer, @serhiy-storchaka
Files
  • test_value.patch
  • reset_buffer.patch
  • 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 2015-05-27.08:58:31.563>
    created_at = <Date 2015-03-27.13:05:10.057>
    labels = ['library']
    title = 'When xdrlib.Packer().pack_string() fails, the Packer is corrupted'
    updated_at = <Date 2015-05-27.08:58:31.563>
    user = 'https://bugs.python.org/ostcar'

    bugs.python.org fields:

    activity = <Date 2015-05-27.08:58:31.563>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-05-27.08:58:31.563>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2015-03-27.13:05:10.057>
    creator = 'ostcar'
    dependencies = []
    files = ['38710', '38711']
    hgrepos = []
    issue_num = 23790
    keywords = ['patch']
    message_count = 4.0
    messages = ['239396', '239410', '239418', '239421']
    nosy_count = 3.0
    nosy_names = ['r.david.murray', 'serhiy.storchaka', 'ostcar']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue23790'
    versions = ['Python 3.4', 'Python 3.5']

    @ostcar
    Copy link
    Mannequin Author

    ostcar mannequin commented Mar 27, 2015

    When xdrlib.Packer().pack_string() is called with an unsupported value, it raises a TypeError. But it calles self.pack_uint(n) before it raises the exception so the buffer is changed.

    There are two possible solutions to solve this behaviour. The argument s can be tested to be supported, or undo the call of self.pack_uint(n).

    I added two alternative patches for this two solutions.

    This is my first patch for cpython, I hope it is ok.

    @ostcar ostcar mannequin added the stdlib Python modules in the Lib dir label Mar 27, 2015
    @bitdancer
    Copy link
    Member

    Your patches are great, thanks. Now we have to decide which to use :)

    @ostcar
    Copy link
    Mannequin Author

    ostcar mannequin commented Mar 27, 2015

    I would prefer the reset_buffer.patch because I do not like argument testing at the begin of a function/method.

    @serhiy-storchaka
    Copy link
    Member

    I doubt that this issue is worth fixing. It is common that when error is happen inside complex operation, the output can be incomplete. When you pickle a list containing non-pickleable data, resulting file content will be not unpickleable. When you write a number of lines in text file, and one of lines contains non-encodable characters, resulting file content will be incomplete and may even don't contain complete lines.

    And when other xdrlib.Packer methods that write complex data (pack_uhyper, pack_list, pack_farray, pack_array) fail, they left incomplete output.

    @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
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants