Skip to content

Commit db670d9

Browse files
committed
res: 583#discussion_r2916262149
Switch to "slices.Contains" for improved readability; negligible performance improvement.
1 parent dc92c67 commit db670d9

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

builder/azure/chroot/builder.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,8 @@ func validateLVMRootDevice(device string) error {
443443
cleaned := posixpath.Clean(device)
444444

445445
// Check for path traversal: reject if any component is ".."
446-
for _, component := range strings.Split(cleaned, "/") {
447-
if component == ".." {
448-
return fmt.Errorf("%q must not contain path traversal (..)", device)
449-
}
446+
if slices.Contains(strings.Split(cleaned, "/"), "..") {
447+
return fmt.Errorf("%q must not contain path traversal (..)", device)
450448
}
451449

452450
if !strings.HasPrefix(cleaned, "/dev/") {

0 commit comments

Comments
 (0)