From 072a27fd9f0d6a34eb33543e14a708ff0567d0d1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 7 Jul 2011 10:55:00 +0200 Subject: s3:libsmb: use trans2_bytes_push_str() in cli_tcon_andx_create() for the plaintext password This makes sure we push the string always in DOS charset. metze --- source3/libsmb/cliconnect.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'source3/libsmb') diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 62e3a35a36..8c51bea9e3 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -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); } } -- cgit