Fix closing of dirs in doSafeMakeDir

This fixes the issue where "childFD" from syscall.Openat is assigned to a local variable inside the for loop, instead of the correct one in the function scope. This results in that when trying to close the "childFD" in the function scope, it will be equal to "-1", instead of the correct value.
parent c5a761cc
...@@ -398,7 +398,7 @@ func doSafeMakeDir(pathname string, base string, perm os.FileMode) error { ...@@ -398,7 +398,7 @@ func doSafeMakeDir(pathname string, base string, perm os.FileMode) error {
return fmt.Errorf("cannot create directory %s: %s", currentPath, err) return fmt.Errorf("cannot create directory %s: %s", currentPath, err)
} }
// Dive into the created directory // Dive into the created directory
childFD, err := syscall.Openat(parentFD, dir, nofollowFlags, 0) childFD, err = syscall.Openat(parentFD, dir, nofollowFlags, 0)
if err != nil { if err != nil {
return fmt.Errorf("cannot open %s: %s", currentPath, err) return fmt.Errorf("cannot open %s: %s", currentPath, err)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment