libsmb: Fix a resource leak in cli_posix_mkdir
authorVolker Lendecke <vl@samba.org>
Wed, 20 Feb 2019 10:55:01 +0000 (11:55 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 22 Feb 2019 20:48:11 +0000 (21:48 +0100)
smbd does posix_mkdir if the wire flags are exactly

if (wire_open_mode == (SMB_O_CREAT|SMB_O_DIRECTORY))

open_flags_to_wire however adds a SMB_O_RDONLY, so that we enter the
normal open routine which happens to create a directory as well. The
main difference is that posix_mkdir does *NOT* return an open
handle. As we did not enter this code path due to the SMB_O_RDONLY we
leak a SMB1 fd per cli_posix_mkdir call.

Pretty hard to test automatically, this would be an interaction with
smbstatus.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/clifile.c

index 61bc73effa22598e20a3e1e9836c3beccc4371a3..ff98ba6003452fe8838058570c920e61cc71886e 100644 (file)
@@ -5348,7 +5348,7 @@ struct tevent_req *cli_posix_mkdir_send(TALLOC_CTX *mem_ctx,
        state->ev = ev;
        state->cli = cli;
 
-       wire_flags = open_flags_to_wire(O_CREAT) | SMB_O_DIRECTORY;
+       wire_flags = SMB_O_CREAT | SMB_O_DIRECTORY;
 
        subreq = cli_posix_open_internal_send(
                mem_ctx, ev, cli, fname, wire_flags, mode);