s3:libsmb: use trans2_bytes_push_str() in cli_tcon_andx_create() for the plaintext...
authorStefan Metzmacher <metze@samba.org>
Thu, 7 Jul 2011 08:55:00 +0000 (10:55 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 7 Jul 2011 12:49:50 +0000 (14:49 +0200)
This makes sure we push the string always in DOS charset.

metze

source3/libsmb/cliconnect.c

index 62e3a35a3693605250d75cd69997d3a56ab5572b..8c51bea9e3f7907f36588573233258657ca112a3 100644 (file)
@@ -2231,7 +2231,7 @@ struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
                if((cli->sec_mode & (NEGOTIATE_SECURITY_USER_LEVEL
                                     |NEGOTIATE_SECURITY_CHALLENGE_RESPONSE))
                   == 0) {
-                       char *tmp_pass;
+                       uint8_t *tmp_pass;
 
                        if (!lp_client_plaintext_auth() && (*pass)) {
                                DEBUG(1, ("Server requested plaintext "
@@ -2244,21 +2244,20 @@ struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
                         * Non-encrypted passwords - convert to DOS codepage
                         * before using.
                         */
-                       tmp_pass = talloc_array(talloc_tos(), char, 128);
-                       if (tmp_pass == NULL) {
-                               tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
+                       tmp_pass = talloc_array(talloc_tos(), uint8, 0);
+                       if (tevent_req_nomem(tmp_pass, req)) {
                                return tevent_req_post(req, ev);
                        }
-                       passlen = clistr_push(cli,
-                                       tmp_pass,
-                                       pass,
-                                       talloc_get_size(tmp_pass),
-                                       STR_TERMINATE);
-                       if (passlen == -1) {
-                               tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
+                       tmp_pass = trans2_bytes_push_str(tmp_pass,
+                                                        false, /* always DOS */
+                                                        pass,
+                                                        passlen,
+                                                        NULL);
+                       if (tevent_req_nomem(tmp_pass, req)) {
                                return tevent_req_post(req, ev);
                        }
-                       pass = tmp_pass;
+                       pass = (const char *)tmp_pass;
+                       passlen = talloc_get_size(tmp_pass);
                }
        }