Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

frame decodes past the end of the input and leaves the state there

未关闭 适合新手
#18 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
tooling

调研方向

从暴露 c.frame 和 State 的包中的 frame 辅助函数开始;它读取声明的长度,并将缓冲区交给子解码器,而没有先检查后面是否有那么多字节。使用 State(bytes.fromhex('0501')) 和 frame(c.uint) 重现,并确认参考实现拒绝。当该输入被拒绝而不是返回 1,State.remaining 从不为负,并且语料库用例 frame-uint-length-past-the-end 与现有的 frame 测试一起通过时,即完成。

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

描述

Found by running the compact-encoding-test conformance corpus against this port.

frame decodes a frame whose announced length is longer than the bytes that follow it, and leaves the state past the end of the buffer rather than refusing:

import compact_encoding as c

s = c.State(bytes.fromhex('0501'))     # a frame announcing 5 bytes, with 1 following
print(c.frame(c.uint).decode(s))       # 1
print(s.start, len(s.buffer))          # 6 2
print(s.remaining)                     # -4

The reference rejects these bytes. remaining going negative is the part that matters beyond the wrong answer: a later read from the same state is working from a position past the buffer, so a truncated or hostile frame corrupts everything decoded after it rather than failing where the problem is.

The corpus case is frame-uint-length-past-the-end, citing the rule frame-rejects-a-length-past-the-end: "a decoder rejects a frame announcing more bytes than follow it, rather than reading the value and leaving off past the end of the input, so 0501 is a rejection and not a 1."

Reading the value inside the announced length and rejecting what runs past it is a separate rule, frame-bounds-its-value, which this port passes.

主要语言
Python
星标
1
派生
1
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

holepunchto/compact-encoding-python 的其他 Issue

查看 holepunchto/compact-encoding-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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