]> Cypherpunks repositories - gostls13.git/commitdiff
os: check setStickyBit error in mkdir
authorEugene Kalinin <e.v.kalinin@gmail.com>
Fri, 1 Jun 2018 08:43:16 +0000 (11:43 +0300)
committerIan Lance Taylor <iant@golang.org>
Tue, 5 Jun 2018 14:53:18 +0000 (14:53 +0000)
If an error occurs, delete the newly created directory.

Change-Id: I97e960d24af32f027fb23d5ce3f61959e73f6fb0
Reviewed-on: https://go-review.googlesource.com/115715
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/os/file.go

index eec0bc4d2e0607576428b9e50ab3838e7787a7c3..fa73919620da3d08b35e33c5832fb0ed2981c2e2 100644 (file)
@@ -221,7 +221,12 @@ func Mkdir(name string, perm FileMode) error {
 
        // mkdir(2) itself won't handle the sticky bit on *BSD and Solaris
        if !supportsCreateWithStickyBit && perm&ModeSticky != 0 {
-               setStickyBit(name)
+               e = setStickyBit(name)
+
+               if e != nil {
+                       Remove(name)
+                       return e
+               }
        }
 
        return nil