Visitar URL original
Loading a saved game fails when the save folder isn't the game folder · Issue #1628 · NetHack/NetHack · GitHub
Skip to content

Loading a saved game fails when the save folder isn't the game folder #1628

Description

@daeho-ro

What happens

Starting NetHack with an existing saved game shows a garbled "Who are you?"
screen with a message like:

    freopen of save/501player for compress failed; (2) No such file or directory

and the game usually crashes right after.

When

When the save directory (VAR_PLAYGROUND) is a different folder from the one
NetHack switches into at startup (HACKDIR). Packaged builds such as Homebrew
set these to different folders.

Cause

In src/files.c, plname_from_file() (un)compresses the save file using a
relative path, so it's looked up in the wrong folder. Everywhere else the
full path is built with fqname().

Possible Fix

Use fqname() for those two calls, like the rest of the save code:

nh_uncompress(fqname(gs.SAVEF, SAVEPREFIX, 0));
...
nh_compress(fqname(gs.SAVEF, SAVEPREFIX, 0));

Activity

  1. pat-rankin commented on Jul 16, 2026

    @pat-rankin

    There is no string buffer overflow taking place. The garbling is a result to two different processes writing to the same terminal without coordinating their efforts. So this needs to be fixed, but the situation is not as severe as you're made it sound.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions