From: Volker Lendecke Date: Wed, 20 Feb 2019 10:55:01 +0000 (+0100) Subject: libsmb: Fix a resource leak in cli_posix_mkdir X-Git-Tag: ldb-1.6.1~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5dd67797ca8025c13f55775c4a5892ecf1b53e3e;p=thirdparty%2Fsamba.git libsmb: Fix a resource leak in cli_posix_mkdir 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 61bc73effa2..ff98ba60034 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -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);