s3:smb2cli: don't terminate the pathname in smb2cli_create()
authorStefan Metzmacher <metze@samba.org>
Mon, 5 Sep 2011 16:22:57 +0000 (18:22 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 7 Sep 2011 06:33:41 +0000 (08:33 +0200)
Windows generates NT_STATUS_OBJECT_NAME_INVALID otherwise.

metze

source3/libsmb/smb2cli_create.c

index 50c9816ded404cacec94fee86565cdce52d939d5..68bb98180ecc64f5324f5711e13f56a7fb4b347e 100644 (file)
@@ -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),