Skip to content

Commit 3202f63

Browse files
pipobscuremcollina
authored andcommitted
vfs: give ZipProvider option bags a null prototype
The options passed to `createFileStats()` and to the archive's `add()` and `addSync()` are plain literals, so a property added to `Object.prototype` would reach those callees as if it had been passed on purpose. Create them with a null prototype so only the fields set here are visible. Refs: #65853 Signed-off-by: Philipp Dunkel <pip@pipobscure.com> PR-URL: #65853 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 36d8fce commit 3202f63

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/internal/vfs/providers/ziparchive.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ class ZipFileHandle extends VirtualFileHandle {
219219
// its own modification time; once dirty the file is as new as its close.
220220
#doStat() {
221221
return createFileStats(this.#size, {
222+
__proto__: null,
222223
mode: this.#entryMode,
223224
mtimeMs: this.#dirty || this.#modified === null ? undefined : this.#modified.getTime(),
224225
});
@@ -249,13 +250,15 @@ class ZipFileHandle extends VirtualFileHandle {
249250

250251
async close() {
251252
if (this.#dirty && isWritableFlag(this.flags)) {
252-
await this.#source.add(this.#name, this.#buffer.subarray(0, this.#size), { mode: this.#entryMode });
253+
await this.#source.add(this.#name, this.#buffer.subarray(0, this.#size),
254+
{ __proto__: null, mode: this.#entryMode });
253255
}
254256
await super.close();
255257
}
256258
closeSync() {
257259
if (this.#dirty && isWritableFlag(this.flags)) {
258-
this.#source.addSync(this.#name, this.#buffer.subarray(0, this.#size), { mode: this.#entryMode });
260+
this.#source.addSync(this.#name, this.#buffer.subarray(0, this.#size),
261+
{ __proto__: null, mode: this.#entryMode });
259262
}
260263
super.closeSync();
261264
}

0 commit comments

Comments
 (0)