Title: Double-free in Argument Clinic `str_converter` generated code · Issue #99240 · python/cpython · GitHub
Open Graph Title: Double-free in Argument Clinic `str_converter` generated code · Issue #99240 · python/cpython
X Title: Double-free in Argument Clinic `str_converter` generated code · Issue #99240 · python/cpython
Description: Argument Clinic str_converter generate such code when encoding is set (see function test_str_converter_encoding in file Lib/test/clinic.test): /* -- snip -- */ if (!_PyArg_ParseStack(args, nargs, "esesetes#et#:test_str_converter_encoding...
Open Graph Description: Argument Clinic str_converter generate such code when encoding is set (see function test_str_converter_encoding in file Lib/test/clinic.test): /* -- snip -- */ if (!_PyArg_ParseStack(args, nargs, "...
X Description: Argument Clinic str_converter generate such code when encoding is set (see function test_str_converter_encoding in file Lib/test/clinic.test): /* -- snip -- */ if (!_PyArg_ParseStack(args, nargs, &...
Opengraph URL: https://github.com/python/cpython/issues/99240
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Double-free in Argument Clinic `str_converter` generated code","articleBody":"Argument Clinic `str_converter` generate such code when `encoding` is set\r\n(see function `test_str_converter_encoding` in file Lib/test/clinic.test):\r\n```c\r\n /* -- snip -- */\r\n if (!_PyArg_ParseStack(args, nargs, \"esesetes#et#:test_str_converter_encoding\",\r\n \"idna\", \u0026a, \"idna\", \u0026b, \"idna\", \u0026c, \"idna\", \u0026d, \u0026d_length, \"idna\", \u0026e, \u0026e_length)) {\r\n goto exit;\r\n }\r\n return_value = test_str_converter_encoding_impl(module, a, b, c, d, d_length, e, e_length);\r\n\r\nexit:\r\n /* Cleanup for a */\r\n if (a) {\r\n PyMem_FREE(a);\r\n }\r\n /* Cleanup for b */\r\n if (b) {\r\n PyMem_FREE(b);\r\n }\r\n /* Cleanup for c */\r\n if (c) {\r\n PyMem_FREE(c);\r\n }\r\n /* -- snip -- */\r\n```\r\n\r\nIf parsing `a` successes, `a` will be assigned an address points to an allocated memory.\r\nAfter that, if parsing `b` fails, the memory which `a` points to is freed by function `_PyArg_ParseStack`,\r\nand `_PyArg_ParseStack` returns 0, then control flow goes to label \"exit\".\r\nAt 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.\r\n\r\nThis bug is found in https://github.com/python/cpython/pull/96178 \"Argument Clinic functional test\".\n\n\u003c!-- gh-pr-number: gh-99241 --\u003e\n* PR: gh-99241\n\u003c!-- /gh-pr-number --\u003e\n\n\n\u003c!-- gh-pr-number: gh-99890 --\u003e\n* PR: gh-99890\n\u003c!-- /gh-pr-number --\u003e\n\n\n\u003c!-- gh-pr-number: gh-100352 --\u003e\n* PR: gh-100352\n\u003c!-- /gh-pr-number --\u003e\n\n\n\u003c!-- gh-pr-number: gh-100353 --\u003e\n* PR: gh-100353\n\u003c!-- /gh-pr-number --\u003e\n\n\n\u003c!-- gh-pr-number: gh-100385 --\u003e\n* PR: gh-100385\n\u003c!-- /gh-pr-number --\u003e\n\n\n\u003c!-- gh-pr-number: gh-100386 --\u003e\n* PR: gh-100386\n\u003c!-- /gh-pr-number --\u003e\n","author":{"url":"https://github.com/colorfulappl","@type":"Person","name":"colorfulappl"},"datePublished":"2022-11-08T07:39:40.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/99240/cpython/issues/99240"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4f2ce920-a4f1-c49d-9836-1892721c81dc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A800:14A586:1F2A912:2BA81EA:696937FF |
| html-safe-nonce | 1c6251b938074b93b0571b8d3a574d67908a9cd9998c525199672ab7ab0a46e0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODAwOjE0QTU4NjoxRjJBOTEyOjJCQTgxRUE6Njk2OTM3RkYiLCJ2aXNpdG9yX2lkIjoiODgzODg2NTc0NDI4MzkwODA5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bd5e70b59bc858bbae4b03ccc06828ff788670764b9da8ab49fd5890134f7049 |
| hovercard-subject-tag | issue:1439653113 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/99240/issue_layout |
| twitter:image | https://opengraph.githubassets.com/592f495a658612a0a6e4157c75cbdb90c435b5477de999572baa7a8565b24a09/python/cpython/issues/99240 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/592f495a658612a0a6e4157c75cbdb90c435b5477de999572baa7a8565b24a09/python/cpython/issues/99240 |
| og:image:alt | Argument Clinic str_converter generate such code when encoding is set (see function test_str_converter_encoding in file Lib/test/clinic.test): /* -- snip -- */ if (!_PyArg_ParseStack(args, nargs, "... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | colorfulappl |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d69ac0477df0f87da03b8b06cebd187012d7a930 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width