@std/encoding: decodeAscii85 corrupts delimited data ending in "<", decodeVarint32 reads past the end of the buffer
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- deno, typescript
調査の方向性
Read encoding/ascii85.ts and encoding/varint.ts, focusing on the delimiter removal and the decodeVarint32 loop and bounds checks described in the issue. Run the reproduction with Deno, then add or run focused tests for both cases. Done means delimited ASCII85 round trips when the payload ends in <, and malformed, truncated, or overflowing 32-bit varints throw RangeError.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
decodeAscii85does not round tripencodeAscii85(data, { delimiter: true })when the encoded payload ends in<: the last byte comes back wrong.decodeVarint32accepts truncated input and returns an offset past the end of the buffer, reads a 6th byte, and returns values above0xffffffff.decodeVarintthrows aRangeErroron the same truncated input.
Steps to Reproduce
import { decodeAscii85, encodeAscii85 } from "jsr:@std/[email protected]/ascii85";
import { decodeVarint, decodeVarint32 } from "jsr:@std/[email protected]/varint";
const encoded = encodeAscii85(new Uint8Array([0xc6, 0x91, 0xeb, 0x81]), { delimiter: true });
console.log(encoded, decodeAscii85(encoded));
console.log(decodeVarint32(new Uint8Array([0x80])));
console.log(decodeVarint32(new Uint8Array([0xff, 0xff])));
console.log(decodeVarint32(new Uint8Array([0x80, 0x80, 0x80, 0x80, 0x80, 0x01])));
console.log(decodeVarint32(new Uint8Array([0xff, 0xff, 0xff, 0xff, 0x7f])));
try { console.log(decodeVarint(new Uint8Array([0x80]))); } catch (e) { console.log(String(e)); }
deno run repro.ts
Expected behavior
The first line ends with Uint8Array(4) [ 198, 145, 235, 129 ]. The four decodeVarint32 calls throw RangeError like decodeVarint (truncated, 6 bytes, and above 32 bits).
Actual behavior
<~`f]S<~> Uint8Array(4) [ 198, 145, 235, 131 ]
[ 0, 2 ]
[ 16383, 3 ]
[ 34359738368, 6 ]
[ 34359738367, 5 ]
RangeError: Cannot decode the varint input: Malformed or overflow varint
In encoding/ascii85.ts, replaceAll(/(<~|~>)/g, "") matches the payload's trailing < plus the ~ of the closing ~>, leaving a stray >. In encoding/varint.ts, decodeVarint32 loops with i <= Math.min(buf.length, offset + MaxVarintLen32) instead of <, and never checks the 32-bit bound.
Environment
- OS: Debian 12 (x86_64)
- deno version: 2.9.8
- std version: @std/encoding 1.0.11, also
mainat f834d02
Credit: https://ucsbplse.github.io/
- 主要言語
- TypeScript
- スター
- 3.6k
- フォーク
- 713
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
denoland/std のほかの issue
-
`assertEquals` throws on structurally equal `Error` objects due to different stack trace対応中かも @powerman2026 が 1 日前に担当しました。 オープンbug needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
streams: DelimiterStream leaves delimiter bytes in the output when the delimiter spans more than two chunks対応中かも @helmipradita が 15 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
@std/yaml: stringify() with condenseFlow wraps already quoted keys in a second pair of quotes対応中かも @sebxt が 34 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
@std/ini parse silently drops an entire section when the section name repeats対応中かも @Harsh23Kashyap が 35 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
cli: parseArgs() treats an empty flag value passed without "=" as a positional argument対応中かも @helmipradita が 23 日前に担当しました。 オープンbug needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
denoland/std#7351 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
vercel-labs/ui#1066 ·
メンテナーはふだん 1 日以内に返信
-
fix(factory-cockpit): display active agent/actor name instead of verbose step name in run card badgeオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ranxianglei/billion-context#7597 ·
メンテナーはふだん 1 日以内に返信
-
documentation target:powerpoint
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
tomast1337/PdfLapas#602 ·
メンテナーはふだん 1 日以内に返信
-
kubernetes-ingestor: fetchCRDMapping() runs even when crossplane.enabled is false, logging a 403 ERROR every run対応中かも @kc9ddi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
TeraSky-OSS/backstage-plugins#228 ·