From ae96b2a0f8b8b20e69e9f99a13ff71f169a05cdf Mon Sep 17 00:00:00 2001 From: Michael Eischer <9106997+MichaelEischer@users.noreply.github.com> Date: Sun, 14 Jun 2026 13:55:26 +0200 Subject: [PATCH] mount: fix crash in mountpoint validation (#21879) --- changelog/unreleased/pull-21879 | 7 +++++++ cmd/restic/cmd_mount.go | 2 ++ 2 files changed, 9 insertions(+) create mode 100644 changelog/unreleased/pull-21879 diff --git a/changelog/unreleased/pull-21879 b/changelog/unreleased/pull-21879 new file mode 100644 index 000000000..a64a4900f --- /dev/null +++ b/changelog/unreleased/pull-21879 @@ -0,0 +1,7 @@ +Bugfix: prevent crash in mountpoint validation if mountpoint is inaccessible + +Since restic 0.19.0, the `mount` command validates a mountpoint before loading +the repository. If restic was unable to stat the mountpoint, this would result +in a crash. This has been fixed to correctly return an error instead. + +https://github.com/restic/restic/pull/21879 diff --git a/cmd/restic/cmd_mount.go b/cmd/restic/cmd_mount.go index 2322e6769..010d1a7e0 100644 --- a/cmd/restic/cmd_mount.go +++ b/cmd/restic/cmd_mount.go @@ -227,6 +227,8 @@ func validateMountpoint(mountpoint string, gopts global.Options) error { stat, err := os.Stat(mountpoint) if errors.Is(err, os.ErrNotExist) { return errors.Fatal(fmt.Sprintf("mountpoint %s does not exist", mountpoint)) + } else if err != nil { + return errors.Fatal(fmt.Sprintf("mountpoint %s is inaccessible: %v", mountpoint, err)) } else if !stat.IsDir() { return errors.Fatal(fmt.Sprintf("mountpoint %s is not a directory", mountpoint)) }