s3: smbd: Fix possible directory fd leak if the underlying OS doesn't support fdopendir()
authorJeremy Allison <jra@samba.org>
Wed, 14 Feb 2018 21:23:12 +0000 (13:23 -0800)
committerRalph Boehme <slow@samba.org>
Fri, 23 Feb 2018 21:56:35 +0000 (22:56 +0100)
HPUX has this problem.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13270

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Feb 23 22:56:35 CET 2018 on sn-devel-144

source3/smbd/smb2_query_directory.c

index 430fdca90de6c90c8207ea0c8dd0bb98ba4ab353..888473853d41801735b36b0784c979221930b867 100644 (file)
@@ -343,11 +343,14 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
        if (in_flags & SMB2_CONTINUE_FLAG_REOPEN) {
                int flags;
 
-               dptr_CloseDir(fsp);
+               status = fd_close(fsp);
+               if (tevent_req_nterror(req, status)) {
+                       return tevent_req_post(req, ev);
+               }
 
                /*
-                * dptr_CloseDir() will close and invalidate the fsp's file
-                * descriptor, we have to reopen it.
+                * fd_close() will close and invalidate the fsp's file
+                * descriptor. So we have to reopen it.
                 */
 
                flags = O_RDONLY;