Skip to content

fgets fails to detect EOF #37

@lennart-benschop

Description

@lennart-benschop

Found this when using fgets to read the config file in the 'mc' program.

When fgets reaches the end of file, it should return a NULL pointer. This works in the fab-agon-emulator, but it does not work on real hardware. The file has CRLF line endings and the last line ends with CRLF too.

fgets can read thousands of spurious lines before it finally thinks the end of file is reached for real. This increased the startup time of mc for some users to 2 minutes.

Temporary work-around: use my own function to read lines, based on fread(). fread() is known to reliably detect end of file.

FILE was opened using fopen with "r" mode ("r" for read access, text files). This converts CRLF on input to LF.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions