The Samba-Bugzilla – Attachment 10398 Details for
Bug 10918
closing file descriptor returned from dirfd is undefined and leaks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for this issue
0001-btrfs-don-t-leak-opened-directory-handle.patch (text/plain), 1.82 KB, created by
Noel Power
on 2014-11-04 16:38:36 UTC
(
hide
)
Description:
patch for this issue
Filename:
MIME Type:
Creator:
Noel Power
Created:
2014-11-04 16:38:36 UTC
Size:
1.82 KB
patch
obsolete
>From 21ad42cb37827ecdf67588d2f0d7d5bbe833e0f7 Mon Sep 17 00:00:00 2001 >From: Noel Power <noel.power@suse.com> >Date: Tue, 4 Nov 2014 16:52:49 +0100 >Subject: [PATCH] btrfs: don't leak opened directory handle > >Closing a directory handle file descriptor via close() is undefined, >according to: >http://pubs.opengroup.org/onlinepubs/9699919799/functions/dirfd.html > >Signed-off-by: Noel Power <noel.power@suse.com> >Reviewed-by: David Disseldorp <ddiss@samba.org> >--- > source3/modules/vfs_btrfs.c | 22 ++++++++++++++++------ > 1 file changed, 16 insertions(+), 6 deletions(-) > >diff --git a/source3/modules/vfs_btrfs.c b/source3/modules/vfs_btrfs.c >index 4639d1c..dfab044 100644 >--- a/source3/modules/vfs_btrfs.c >+++ b/source3/modules/vfs_btrfs.c >@@ -269,23 +269,29 @@ static NTSTATUS btrfs_get_compression(struct vfs_handle_struct *handle, > int fd; > bool opened = false; > NTSTATUS status; >+ DIR *dir = NULL; > > if ((fsp != NULL) && (fsp->fh->fd != -1)) { > fd = fsp->fh->fd; > } else if (smb_fname != NULL) { > if (S_ISDIR(smb_fname->st.st_ex_mode)) { >- DIR *dir = opendir(smb_fname->base_name); >+ dir = opendir(smb_fname->base_name); > if (dir == NULL) { > return NT_STATUS_UNSUCCESSFUL; > } >+ opened = true; > fd = dirfd(dir); >+ if (fd < 0) { >+ status = NT_STATUS_UNSUCCESSFUL; >+ goto err_close; >+ } > } else { > fd = open(smb_fname->base_name, O_RDONLY); >+ if (fd < 0) { >+ return NT_STATUS_UNSUCCESSFUL; >+ } >+ opened = true; > } >- if (fd < 0) { >- return NT_STATUS_UNSUCCESSFUL; >- } >- opened = true; > } else { > return NT_STATUS_INVALID_PARAMETER; > } >@@ -305,7 +311,11 @@ static NTSTATUS btrfs_get_compression(struct vfs_handle_struct *handle, > status = NT_STATUS_OK; > err_close: > if (opened) { >- close(fd); >+ if (dir != NULL) { >+ closedir(dir); >+ } else { >+ close(fd); >+ } > } > > return status; >-- >1.8.4.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
ddiss
:
review+
Actions:
View
Attachments on
bug 10918
:
10398
|
10429