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
平均合併
4 天 6 小時
30 天內合併 PR
1

環境準備

這個專案沒有提供開發容器、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 摘要。