mirror of
https://github.com/restic/restic.git
synced 2026-06-17 22:24:17 +00:00
mount: fix crash in mountpoint validation (#21879)
This commit is contained in:
@@ -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
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user