Skip to content

Potential null pointer dereference in PySys_AddWarnOptionUnicode #126108

Closed

Description

@federicovalenso

Bug report

Bug description:

Pointer tstate is compared to a NULL value here, but above there is a dereference. Stack trace: _PySys_AddWarnOptionWithError -> get_warnoptions -> _PySys_GetAttr. Correct code should look like this:

void
PySys_AddWarnOptionUnicode(PyObject *option)
{
    PyThreadState *tstate = _PyThreadState_GET();
    if (tstate && _PySys_AddWarnOptionWithError(tstate, option) < 0) {
        /* No return value, therefore clear error state if possible */
        _PyErr_Clear(tstate);
    }
}

CPython versions tested on:

3.11

Operating systems tested on:

No response

Linked PRs

Activity

  1. changed the title [-]Potential null pointer dereference[/-] [+]Potential null pointer dereference in `PySys_AddWarnOptionUnicode`[/+] on Oct 29, 2024
  2. added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    3.12only security fixes
    3.13only security fixes
    3.14bugs and security fixes
    on Oct 29, 2024
  3. picnixz commented on Oct 29, 2024

    @picnixz
    Member

    Thanks for spotting this. This still happens on main. Feel free to open a PR (I can do it as well if you want).

    Note: 3.11 is security-only and this does not seem to count as a security issue unless someone is able to provide me a PoC of an exploit using that null pointer dereference.

  4. picnixz commented on Oct 29, 2024

    @picnixz
    Member

    cc @sobolevn since you are working on this batch of issues

  5. sobolevn commented on Oct 29, 2024

    @sobolevn
    Member

    I haven't seen this one yet :)

  6. added a commit that references this issue on Jan 31, 2025
  7. added 2 commits that reference this issue on Jan 31, 2025
  8. added 2 commits that reference this issue on Jan 31, 2025
  9. added a commit that references this issue on Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13only security fixes3.14bugs and security fixeseasyinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions