Skip to content

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

Closed

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.

Activity

  1. added
    confirmed-bugIssues and PRs for confirmed bugs.
    fsIssues and PRs related to file-system APIs and the fs module.
    on Mar 5, 2015
  2. brendanashworth commented on Mar 25, 2015

    @brendanashworth
    Contributor

    I think this should be fixed in #1074, closing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.fsIssues and PRs related to file-system APIs and the fs module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions