From 585ec4da977058ee312140ac6fe1bbeea32fc841 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 9 Dec 2019 15:32:02 +0100 Subject: [PATCH] docker cp: prevent NPE when failing to stat destination Signed-off-by: Sebastiaan van Stijn --- cli/command/utils.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cli/command/utils.go b/cli/command/utils.go index 254f6e15cc..ec89062d37 100644 --- a/cli/command/utils.go +++ b/cli/command/utils.go @@ -139,6 +139,10 @@ func ValidateOutputPath(path string) error { // check whether `path` points to a regular file // (if the path exists and doesn't point to a directory) if fileInfo, err := os.Stat(path); !os.IsNotExist(err) { + if err != nil { + return err + } + if fileInfo.Mode().IsDir() || fileInfo.Mode().IsRegular() { return nil }