Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Possible segfault if globals dict is NULL in run_eval_code_obj #116180

@ngr-ilmarh

Description

@ngr-ilmarh

Bug report

Bug description:

Possible interpreter crash condition was found by Linux Verification Center (portal.linuxtesting.ru) with SVACE.

run_eval_code_obj is called with globals dict passed as pointer without NULL check and that may cause segmentation fault in

PyEval_EvalCode->_PyEval_BuiltinsFromGlobals->PyDict_GetItemWithError line 2272 in PyDict_Check(op).

Some functions, for example, _run_script or builtin_eval_impl have globals NULL check.

Other, like PyRun_SimpleStringFlags,
PyRun_InteractiveOneObjectEx or PyRun_FileExFlags just use the pointer from the PyObject struct.

For my understanding the globals dict should always be present and it is an error condition, when it is NULL.
And no one encounted with such faults, so the patch will have cosmetic effect (is on the way).

CPython versions tested on:

3.10

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions