vfs: ZipProvider allows creating entries beneath non-directory parents · Issue #65828 · nodejs/node · GitHub
Skip to content

vfs: ZipProvider allows creating entries beneath non-directory parents #65828

Description

@trivikr

Version

main

Platform

macOS

Subsystem

vfs

What steps will reproduce the bug?

import { createZipArchive, ZipBuffer, ZipEntry } from 'node:zlib';
import { create, ZipProvider } from 'node:vfs';

const zipEntry = await ZipEntry.create('file.txt', Buffer.from('contents'));
const zipArchive = createZipArchive([zipEntry]);
const archive = Buffer.concat(await Array.fromAsync(zipArchive));
const fs = create(new ZipProvider(new ZipBuffer(archive)));

try {
  await fs.promises.writeFile('/file.txt/child.txt', 'hello');
  console.log('write succeeded');
} catch (error) {
  console.log(`${error.code}: ${error.message}`);
}

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

It should fail with ENOTDIR

What do you see instead?

write succeeded

The write incorrectly succeeds even though file.txt is not a directory

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

vfsIssues and PRs related to the virtual filesystem subsystem.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions