E671 gh-99240: Fix double-free bug in Argument Clinic str_converter generated code by colorfulappl · Pull Request #99241 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-99240: Fix double-free bug in Argument Clinic str_converter generated code #99241

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

Merged
merged 13 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

10000
Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Delete unnecessary function doc
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
  • Loading branch information
colorfulappl and erlend-aasland committed Nov 24, 2022
commit 7767139f8c6a9ae58181ebc998b0b61a54717dd7
11 changes: 1 addition & 10 deletions Modules/_testclinic.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,20 +959,11 @@ gh_99240_double_free

Proof-of-concept of GH-99240 double-free bug.

If parsing `a` successes, `a` will be assigned an address points to an allocated memory.
After that, if parsing `b` fails, the memory which `a` points to is freed by function `_PyArg_ParseStack`,
and `_PyArg_ParseStack` returns 0, then control flow goes to label "exit".
At this time, `a` is not NULL, so the memory it points to is freed again,
which cause a double-free problem and a runtime crash.

Calling this function by gh_99240_double_free('a', '\0b')
to trigger this bug (crash).

[clinic start generated code]*/

static PyObject *
gh_99240_double_free_impl(PyObject *module, char *a, char *b)
/*[clinic end generated code: output=586dc714992fe2ed input=419d3a3790de435e]*/
/*[clinic end generated code: output=586dc714992fe2ed input=23db44aa91870fc7]*/
{
Py_RETURN_NONE;
}
Expand Down
13 changes: 2 additions & 11 deletions Modules/clinic/_testclinic.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0