Skip to content

fs.readFile[Sync]("/dev/stdin") does not always read the entire file #1070

Closed
@piscisaureus

Description

@piscisaureus

Originally reported here: nodejs/node-v0.x-archive#7412

The root cause of the issue is that fs.readFile() stats the file and reads the amount of bytes specified in the st_size field. This works only for regular files.

The fix would be to check whether the ST_IFREG flag is set. If not, use a slower but more reliable method to read the entire file.

I think this is a "good first bug" for new contributors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions