a[i] = v past a read-only length grows the array instead of failing

オープン 初心者向け
#1,970 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
79/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, javascript
領域
backend, compilers

調査の方向性

quickjs.c の OP_put_array_el のインライン高速パス(20164~20171 行付近)から始め、length の処理を add_fast_array_element および JS_SetPropertyValue と比較してください。length が書き込み不可の場合の、sloppy mode と strict mode の両方における配列への代入動作を確認してください。sloppy mode では配列の length が 2 のままで、strict mode では TypeError がスローされれば完了です。

索引モデルが issue の本文から書いたものです。

説明

With a non-writable length, assigning past the end grows the array in the inline fast path.

const a = [0, 0, 0, 0];
a.length = 2;
Object.defineProperty(a, "length", { writable: false });
a[2] = "x";
console.log(a.length);

Expected: 2 (sloppy mode; strict mode throws TypeError)
Actual (observed): 3

Spec: Array [[DefineOwnProperty]]: an index >= length with length not writable returns false.
Version: quickjs-ng master, revision not recorded in the test build (source read at a36054a). Built with the quickjs-ng on our build host.

Fix note: the inline path of OP_put_array_el (quickjs.c:20164-20171) writes length without a JS_PROP_WRITABLE check. add_fast_array_element (:10674) and JS_SetPropertyValue (:11028) do check it.
Related: #1882 (same class, different site).

We found this while fuzzing.

Credit: https://ucsbplse.github.io/

主要言語
C
スター
3.9k
フォーク
389
平均マージ
2日 2時間
マージ済み PR(30日)
21

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quickjs-ng/quickjs のほかの issue

quickjs-ng/quickjs の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。