python / python/cpython

Add overflow checks before calling memory allocators

未关闭
#127,681 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

extension-modules interpreter-core stale type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:

From https://github.com/capi-workgroup/decisions/issues/50#issuecomment-2522706899 and https://github.com/capi-workgroup/decisions/issues/50#issuecomment-2514640058.

Some calls to the PyMem_* API uses an arithmetic operation on the size, which could make the requested length overflow. The checks in the corresponding functions would not be relevant since the inputs already overflowed.

See https://github.com/python/cpython/pull/127686#issuecomment-2523699454 for the future of this issue.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-153489

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先检查 CPython 主分支中的 PyMem_* 分配器调用,以及 gh-153489 中链接的讨论。跟踪分配前的每个大小算术运算,然后验证在调用分配器之前已处理溢出情况。

由索引模型根据 Issue 内容生成。

评估

技术栈
c
领域
backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。