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

Patch for "string without null bytes" check in getargs.c #46551

Closed
duggelz mannequin opened this issue Mar 16, 2008 · 6 comments
Closed

Patch for "string without null bytes" check in getargs.c #46551

duggelz mannequin opened this issue Mar 16, 2008 · 6 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@duggelz
Copy link
Mannequin

duggelz mannequin commented Mar 16, 2008

BPO 2298
Nosy @birkenfeld, @abalkin, @duggelz, @avassalotti
Superseder
  • bpo-2322: Clean up getargs.c and its formatting possibilities
  • Files
  • py3k-getargs-null-bytes-20080315.diff
  • unnamed
  • 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 2008-03-21.20:47:15.731>
    created_at = <Date 2008-03-16.06:00:38.347>
    labels = ['interpreter-core', 'type-bug']
    title = 'Patch for "string without null bytes" check in getargs.c'
    updated_at = <Date 2008-03-21.20:47:15.729>
    user = 'https://github.com/duggelz'

    bugs.python.org fields:

    activity = <Date 2008-03-21.20:47:15.729>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-03-21.20:47:15.731>
    closer = 'georg.brandl'
    components = ['Interpreter Core']
    creation = <Date 2008-03-16.06:00:38.347>
    creator = 'dgreiman'
    dependencies = []
    files = ['9679', '9688']
    hgrepos = []
    issue_num = 2298
    keywords = ['patch']
    message_count = 6.0
    messages = ['63571', '63582', '63643', '63652', '63684', '64278']
    nosy_count = 4.0
    nosy_names = ['georg.brandl', 'belopolsky', 'dgreiman', 'alexandre.vassalotti']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '2322'
    type = 'behavior'
    url = 'https://bugs.python.org/issue2298'
    versions = ['Python 3.0']

    @duggelz
    Copy link
    Mannequin Author

    duggelz mannequin commented Mar 16, 2008

    Code in getargs.c:convertsimple incorrectly uses PyUnicode_GetSize
    instead of PyString_GET_SIZE when checking whether a bytes object
    (encoded string) contains a null byte.

    To reproduce: __import__('\u0080')
    Incorrect behavior:
    TypeError: __import__() argument 1 must be string without null bytes,
    not str
    Correct behavior:
    ImportError

    Note the lack of null bytes:
      >>> '\u0080'.encode('utf-8')
      b'\xc2\x80'

    @duggelz duggelz mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Mar 16, 2008
    @abalkin
    Copy link
    Member

    abalkin commented Mar 16, 2008

    Note that this patch will expose a bug fixed in bpo-1950. (See msg63363.) I suggest that the import.c part of bpo-1950 and this go
    together. Alexandre?

    @avassalotti
    Copy link
    Member

    Yes, that sounds like a good idea. Although I haven't reviewed this
    patch yet, I find the naming of the ustr variable confusing -- e.g. is
    it a bytes object or a unicode object? (It seems to be bytes). Anyway, I
    will check this out later today, when I will get the time.

    @abalkin
    Copy link
    Member

    abalkin commented Mar 17, 2008

    On Mon, Mar 17, 2008 at 9:51 AM, Alexandre Vassalotti <
    report@bugs.python.org> wrote:

    Alexandre Vassalotti alexandre@peadrop.com added the comment:

    .. Although I haven't reviewed this
    patch yet, I find the naming of the ustr variable confusing -- e.g. is
    it a bytes object or a unicode object?

    There is no ustr variable , you probably mean uarg. If so, it is
    not introduced by the patch. To me the patch looks straightforward and
    correct, but a unit test should be added. Some additional refactoring is
    due for getargs.c (does py3k support builds without Py_USING_UNICODE?), but
    the bug fix should not wait for that.

    @abalkin
    Copy link
    Member

    abalkin commented Mar 17, 2008

    There is now bpo-2322 (Clean up getargs.c and its formatting
    possibilities) related to this.

    @birkenfeld
    Copy link
    Member

    I've added XXX comments to the code, so this is now tracked by bpo-2322.

    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants