@@ -16,6 +16,7 @@ import (
1616 "strings"
1717
1818 "github.com/containers/buildah"
19+ "github.com/containers/podman/v6/internal/localapi"
1920 "github.com/containers/podman/v6/libpod"
2021 "github.com/containers/podman/v6/libpod/define"
2122 "github.com/containers/podman/v6/pkg/api/handlers"
@@ -41,7 +42,6 @@ import (
4142 "go.podman.io/storage"
4243 "go.podman.io/storage/pkg/archive"
4344 "go.podman.io/storage/pkg/chrootarchive"
44- "go.podman.io/storage/pkg/fileutils"
4545 "go.podman.io/storage/pkg/idtools"
4646)
4747
@@ -396,10 +396,13 @@ func ImagesLocalLoad(w http.ResponseWriter, r *http.Request) {
396396
397397 cleanPath := filepath .Clean (query .Path )
398398 // Check if the path exists on server side.
399- // Note: fileutils.Exists returns nil if the file exists, not an error.
400- switch err := fileutils . Exists (cleanPath ); {
399+ // Note: localapi.ValidatePathForLocalAPI returns nil if the file exists and path is absolute , not an error.
400+ switch err := localapi . ValidatePathForLocalAPI (cleanPath ); {
401401 case err == nil :
402402 // no error -> continue
403+ case errors .Is (err , localapi .ErrPathNotAbsolute ):
404+ utils .Error (w , http .StatusBadRequest , err )
405+ return
403406 case errors .Is (err , fs .ErrNotExist ):
404407 utils .Error (w , http .StatusNotFound , fmt .Errorf ("file does not exist: %q" , cleanPath ))
405408 return
0 commit comments