s3:libsmb: use trans2_bytes_push_str() in cli_dfs_get_referral()
authorStefan Metzmacher <metze@samba.org>
Wed, 6 Jul 2011 16:36:29 +0000 (18:36 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 7 Jul 2011 12:49:49 +0000 (14:49 +0200)
metze

source3/libsmb/clidfs.c

index 5d97cd3011a7a013bbfca692c291ecbdae90bf8f..a0d503a802d66a3f378e5ebe25d9f02730156e73 100644 (file)
@@ -614,7 +614,6 @@ NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
        uint8_t *rdata = NULL;
        char *p;
        char *endp;
-       size_t pathlen = 2*(strlen(path)+1);
        smb_ucs2_t *path_ucs;
        char *consumed_path = NULL;
        uint16_t consumed_ucs;
@@ -628,17 +627,22 @@ NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
 
        SSVAL(setup, 0, TRANSACT2_GET_DFS_REFERRAL);
 
-       param = talloc_array(talloc_tos(), uint8_t, 2+pathlen+2);
+       param = talloc_array(talloc_tos(), uint8_t, 2);
        if (!param) {
                status = NT_STATUS_NO_MEMORY;
                goto out;
        }
        SSVAL(param, 0, 0x03);  /* max referral level */
-       p = (char *)(&param[2]);
 
-       path_ucs = (smb_ucs2_t *)p;
-       p += clistr_push(cli, p, path, pathlen, STR_TERMINATE);
-       param_len = PTR_DIFF(p, param);
+       param = trans2_bytes_push_str(param, cli_ucs2(cli),
+                                     path, strlen(path)+1,
+                                     NULL);
+       if (!param) {
+               status = NT_STATUS_NO_MEMORY;
+               goto out;
+       }
+       param_len = talloc_get_size(param);
+       path_ucs = (smb_ucs2_t *)&param[2];
 
        status = cli_trans(talloc_tos(), cli, SMBtrans2,
                           NULL, 0xffff, 0, 0,