mirror of
https://github.com/minio/minio.git
synced 2024-12-25 14:45:54 -05:00
fs: Filter out valid paths and volnames. (#1321)
This commit is contained in:
parent
b2ec7da9f9
commit
33633fd15d
@ -134,7 +134,7 @@ func treeWalk(bucketDir, prefixDir, entryPrefixMatch, marker string, recursive b
|
|||||||
hasReserved := hasReservedPrefix(dirent.name) || hasReservedSuffix(dirent.name)
|
hasReserved := hasReservedPrefix(dirent.name) || hasReservedSuffix(dirent.name)
|
||||||
// All dirents which match prefix and do not have reserved
|
// All dirents which match prefix and do not have reserved
|
||||||
// keywords in them are valid entries.
|
// keywords in them are valid entries.
|
||||||
return strings.HasPrefix(dirent.name, entryPrefixMatch) && !hasReserved
|
return strings.HasPrefix(dirent.name, entryPrefixMatch) && !hasReserved && isValidPath(dirent.name)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func isValidPath(path string) bool {
|
|||||||
// isValidPrefix verifies where the prefix is a valid path.
|
// isValidPrefix verifies where the prefix is a valid path.
|
||||||
func isValidPrefix(prefix string) bool {
|
func isValidPrefix(prefix string) bool {
|
||||||
// Prefix can be empty.
|
// Prefix can be empty.
|
||||||
if prefix == "" {
|
if prefix == "" || prefix == "/" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Verify if prefix is a valid path.
|
// Verify if prefix is a valid path.
|
||||||
|
2
fs.go
2
fs.go
@ -143,7 +143,7 @@ func removeDuplicateVols(vols []VolInfo) []VolInfo {
|
|||||||
func getAllUniqueVols(dirPath string) ([]VolInfo, error) {
|
func getAllUniqueVols(dirPath string) ([]VolInfo, error) {
|
||||||
volumeFn := func(dirent fsDirent) bool {
|
volumeFn := func(dirent fsDirent) bool {
|
||||||
// Return all directories.
|
// Return all directories.
|
||||||
return dirent.IsDir()
|
return dirent.IsDir() && isValidVolname(dirent.name)
|
||||||
}
|
}
|
||||||
namesOnly := false // Returned dirent names are absolute.
|
namesOnly := false // Returned dirent names are absolute.
|
||||||
dirents, err := scandir(dirPath, volumeFn, namesOnly)
|
dirents, err := scandir(dirPath, volumeFn, namesOnly)
|
||||||
|
Loading…
Reference in New Issue
Block a user