createImageData() with negative width and height aborts the process
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
調査の方向性
まず、issueで名前が挙げられている Context2d::CreateImageData を読み、バッファを割り当てる前に幅と高さをどのように変換するかを追ってください。引用されているCanvas仕様と動作を比較し、提供されたスクリプトにある負のサイズの2つのケースを再現してください。完了条件は、どちらも例外を発生させたり異常終了したりせず、正の寸法を返すことです。それらのケースに絞ったテストを追加するか、実行してください。
索引モデルが issue の本文から書いたものです。
説明
Version of node-canvas
v3.2.3, v4.0.0-rc3 (master 6cc138b)
Version of node
v26.13.0
What operating system does the problem occur on?
Linux
Steps to reproduce
ctx.createImageData(sw, sh) should use the absolute values of sw and sh. In node-canvas a negative size is read as a huge unsigned number: one negative argument throws, and two negative arguments abort Node with a fatal out-of-memory error that cannot be caught.
const { createCanvas } = require('canvas');
const ctx = createCanvas(10, 10).getContext('2d');
try { const d = ctx.createImageData(-3, 2); console.log(d.width, d.height); } catch (e) { console.log('threw:', e.message); }
const d = ctx.createImageData(-3, -2);
console.log(d.width, d.height);
Run node repro.js; echo $?:
Actual:
threw: buffer exceeds 2147483647 bytes
FATAL ERROR: v8::ArrayBuffer::New Allocation failed - process out of memory
...
134
Expected (matches Chrome 153):
3 2
3 2
Additional information/comments
Per https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createimagedata, createImageData(sw, sh) must initialize the ImageData object with the absolute magnitude of sw and sh. In Context2d::CreateImageData, the arguments are converted with Uint32Value(), turning -3 into 4294967293; with two negative values Bpp * width * height overflows int64_t, bypasses the nBytes > INT32_MAX check, and passes a negative nBytes to Napi::ArrayBuffer::New.
Credit: https://ucsbplse.github.io/
- 主要言語
- JavaScript
- スター
- 10.7k
- フォーク
- 1.2k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Automattic/node-canvas のほかの issue
-
Feature Text & Fonts
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
Automattic/node-canvas#2364 · コメント 3 件 · リアクション 2 件 ·
-
Feature
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
Automattic/node-canvas#2621 ·
-
actualBoundingBoxLeft has the sign inverted relative to canvas's own rasteriser (3.2.0, 3.2.3)対応中かも @florianaltendorfer が 13 日前に担当しました。 オープンBug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
Automattic/node-canvas#2620 · コメント 1 件 ·
-
Bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Automattic/node-canvas#2619 · コメント 1 件 ·
-
The PDF file created by createPDFStream becomes larger in size, and createWriteStream is very slowオープンBug performance
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Automattic/node-canvas#2615 · コメント 2 件 ·
Automattic/node-canvas の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
capricorn86/happy-dom#2594 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
microsoft/monaco-editor#5575 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
Shrinking an array with `length =` and growing it back loses the patches for the truncated indices対応中かも @RClaudiuM が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 4 日以内に返信