From: Stefan Metzmacher Date: Mon, 5 Sep 2011 16:22:57 +0000 (+0200) Subject: s3:smb2cli: don't terminate the pathname in smb2cli_create() X-Git-Url: http://git.samba.org/?p=metze%2Fsamba%2Fwip.git;a=commitdiff_plain;h=96a3ec51b40ff6d84d7194dcd5386884f00122bd s3:smb2cli: don't terminate the pathname in smb2cli_create() Windows generates NT_STATUS_OBJECT_NAME_INVALID otherwise. metze --- diff --git a/source3/libsmb/smb2cli_create.c b/source3/libsmb/smb2cli_create.c index 50c9816ded40..68bb98180ecc 100644 --- a/source3/libsmb/smb2cli_create.c +++ b/source3/libsmb/smb2cli_create.c @@ -77,12 +77,17 @@ struct tevent_req *smb2cli_create_send( } if (!convert_string_talloc(state, CH_UNIX, CH_UTF16, - filename, strlen(filename)+1, + filename, strlen(filename), &name_utf16, &name_utf16_len)) { tevent_req_oom(req); return tevent_req_post(req, ev); } + if (strlen(filename) == 0) { + TALLOC_FREE(name_utf16); + name_utf16_len = 0; + } + fixed = state->fixed; SSVAL(fixed, 0, 57); @@ -118,8 +123,10 @@ struct tevent_req *smb2cli_create_send( return tevent_req_post(req, ev); } - memcpy(dyn, name_utf16, name_utf16_len); - TALLOC_FREE(name_utf16); + if (name_utf16) { + memcpy(dyn, name_utf16, name_utf16_len); + TALLOC_FREE(name_utf16); + } if (blob.data != NULL) { memcpy(dyn + blobs_offset - (SMB2_HDR_BODY + 56),