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

Objects/structseq.c: warning: 'strncpy' specified bound depends on the length of the source argument #80546

Closed
vstinner opened this issue Mar 19, 2019 · 3 comments
Labels
3.8 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@vstinner
Copy link
Member

BPO 36365
Nosy @vstinner
PRs
  • bpo-36365: Rewrite structseq_repr() using _PyUnicodeWriter #12440
  • [3.7] bpo-36365: Fix compiler warning in structseq.c #12451
  • 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 2019-03-19.23:06:20.175>
    created_at = <Date 2019-03-19.14:57:37.473>
    labels = ['interpreter-core', '3.8']
    title = "Objects/structseq.c: warning: 'strncpy' specified bound depends on the length of the source argument"
    updated_at = <Date 2019-03-19.23:32:21.585>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-03-19.23:32:21.585>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-03-19.23:06:20.175>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2019-03-19.14:57:37.473>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36365
    keywords = ['patch']
    message_count = 3.0
    messages = ['338361', '338416', '338419']
    nosy_count = 1.0
    nosy_names = ['vstinner']
    pr_nums = ['12440', '12451']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue36365'
    versions = ['Python 3.8']

    @vstinner
    Copy link
    Member Author

    Warning seen on Fedora 29 with GCC 8.3.1 20190223 (Red Hat 8.3.1-2):

    Objects/structseq.c: In function 'structseq_repr':
    Objects/structseq.c:187:5: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-overflow=]
    strncpy(pbuf, typ->tp_name, len);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Objects/structseq.c:185:11: note: length computed here
    len = strlen(typ->tp_name) > TYPE_MAXSIZE ? TYPE_MAXSIZE :
    ^~~~~~~~~~~~~~~~~~~~

    Attached PR rewrites structseq_repr() using _PyUnicodeWriter for better performance and remove the arbitrary limit of 512 bytes.

    @vstinner vstinner added 3.8 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Mar 19, 2019
    @vstinner
    Copy link
    Member Author

    New changeset c70ab02 by Victor Stinner in branch 'master':
    bpo-36365: Rewrite structseq_repr() using _PyUnicodeWriter (GH-12440)
    c70ab02

    @vstinner
    Copy link
    Member Author

    New changeset ea3592d by Victor Stinner in branch '3.7':
    bpo-36365: Fix compiler warning in structseq.c (GH-12451)
    ea3592d

    @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.8 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant