diff options
author | Jakob Unterwurzacher | 2019-01-01 20:49:56 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2019-01-01 20:49:56 +0100 |
commit | cd0ec342b9692c71c50c77caa7b9cfde27426e4d (patch) | |
tree | e5ba0c5b437178369a1c752d0966803bb0ee9edb /internal/fusefrontend | |
parent | 77c3df48ef76aa8fa68744fec1ca19ca28fc13e3 (diff) |
fusefrontend: fix fd leak in error path
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r-- | internal/fusefrontend/ctlsock_interface.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/internal/fusefrontend/ctlsock_interface.go b/internal/fusefrontend/ctlsock_interface.go index 92de40f..b29d150 100644 --- a/internal/fusefrontend/ctlsock_interface.go +++ b/internal/fusefrontend/ctlsock_interface.go @@ -67,16 +67,15 @@ func (fs *FS) decryptPathAt(dirfd int, cipherPath string) (plainPath string, err break } // Descend into next directory - oldWd := wd wd, err = syscallcompat.Openat(wd, part, syscall.O_NOFOLLOW, 0) if err != nil { return "", err } - // Unless we are in the first iteration, where dirfd is our wd, close - // the old working directory. - if i > 0 { - syscall.Close(oldWd) - } + // Yes this is somewhat wasteful in terms of used file descriptors: + // we keep them all open until the function returns. But it is simple + // and reliable. + defer syscall.Close(wd) } + return plainPath, nil } |