mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
r26652: msrpc_parse/msrpc_gen: Add iconv_convenience argument.
This commit is contained in:
parent
9f64213463
commit
e886f1bc0d
@ -157,6 +157,7 @@ static NTSTATUS gensec_ntlmssp_update_find(struct gensec_ntlmssp_state *gensec_n
|
||||
}
|
||||
} else {
|
||||
if (!msrpc_parse(gensec_ntlmssp_state,
|
||||
lp_iconv_convenience(gensec_security->lp_ctx),
|
||||
&input, "Cd",
|
||||
"NTLMSSP",
|
||||
&ntlmssp_command)) {
|
||||
|
@ -62,6 +62,7 @@ NTSTATUS ntlmssp_client_initial(struct gensec_security *gensec_security,
|
||||
|
||||
/* generate the ntlmssp negotiate packet */
|
||||
msrpc_gen(out_mem_ctx,
|
||||
lp_iconv_convenience(gensec_security->lp_ctx),
|
||||
out, "CddAA",
|
||||
"NTLMSSP",
|
||||
NTLMSSP_NEGOTIATE,
|
||||
@ -111,6 +112,7 @@ NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
|
||||
}
|
||||
|
||||
if (!msrpc_parse(mem_ctx,
|
||||
lp_iconv_convenience(gensec_security->lp_ctx),
|
||||
&in, "CdBd",
|
||||
"NTLMSSP",
|
||||
&ntlmssp_command,
|
||||
@ -148,6 +150,7 @@ NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
|
||||
}
|
||||
|
||||
if (!msrpc_parse(mem_ctx,
|
||||
lp_iconv_convenience(gensec_security->lp_ctx),
|
||||
&in, chal_parse_string,
|
||||
"NTLMSSP",
|
||||
&ntlmssp_command,
|
||||
@ -244,6 +247,7 @@ NTSTATUS ntlmssp_client_challenge(struct gensec_security *gensec_security,
|
||||
|
||||
/* this generates the actual auth packet */
|
||||
if (!msrpc_gen(mem_ctx,
|
||||
lp_iconv_convenience(gensec_security->lp_ctx),
|
||||
out, auth_gen_string,
|
||||
"NTLMSSP",
|
||||
NTLMSSP_AUTH,
|
||||
|
@ -41,7 +41,9 @@
|
||||
d = word (4 bytes)
|
||||
C = constant ascii string
|
||||
*/
|
||||
bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
|
||||
bool msrpc_gen(TALLOC_CTX *mem_ctx,
|
||||
struct smb_iconv_convenience *iconv_convenience,
|
||||
DATA_BLOB *blob,
|
||||
const char *format, ...)
|
||||
{
|
||||
int i;
|
||||
@ -65,7 +67,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
|
||||
case 'U':
|
||||
s = va_arg(ap, char *);
|
||||
head_size += 8;
|
||||
n = push_ucs2_talloc(pointers, lp_iconv_convenience(global_loadparm), (void **)&pointers[i].data, s);
|
||||
n = push_ucs2_talloc(pointers, iconv_convenience, (void **)&pointers[i].data, s);
|
||||
if (n == -1) {
|
||||
return false;
|
||||
}
|
||||
@ -76,7 +78,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
|
||||
case 'A':
|
||||
s = va_arg(ap, char *);
|
||||
head_size += 8;
|
||||
n = push_ascii_talloc(pointers, lp_iconv_convenience(global_loadparm), (char **)&pointers[i].data, s);
|
||||
n = push_ascii_talloc(pointers, iconv_convenience, (char **)&pointers[i].data, s);
|
||||
if (n == -1) {
|
||||
return false;
|
||||
}
|
||||
@ -88,7 +90,7 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
|
||||
n = va_arg(ap, int);
|
||||
intargs[i] = n;
|
||||
s = va_arg(ap, char *);
|
||||
n = push_ucs2_talloc(pointers, lp_iconv_convenience(global_loadparm), (void **)&pointers[i].data, s);
|
||||
n = push_ucs2_talloc(pointers, iconv_convenience, (void **)&pointers[i].data, s);
|
||||
if (n == -1) {
|
||||
return false;
|
||||
}
|
||||
@ -199,7 +201,9 @@ if ((head_ofs + amount) > blob->length) { \
|
||||
C = constant ascii string
|
||||
*/
|
||||
|
||||
bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
|
||||
bool msrpc_parse(TALLOC_CTX *mem_ctx,
|
||||
struct smb_iconv_convenience *iconv_convenience,
|
||||
const DATA_BLOB *blob,
|
||||
const char *format, ...)
|
||||
{
|
||||
int i;
|
||||
@ -244,7 +248,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
|
||||
}
|
||||
|
||||
if (0 < len1) {
|
||||
pull_string(lp_iconv_convenience(global_loadparm), p, blob->data + ptr, p_len,
|
||||
pull_string(iconv_convenience, p, blob->data + ptr, p_len,
|
||||
len1, STR_UNICODE|STR_NOALIGN);
|
||||
(*ps) = talloc_strdup(mem_ctx, p);
|
||||
if (!(*ps)) {
|
||||
@ -279,7 +283,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
|
||||
}
|
||||
|
||||
if (0 < len1) {
|
||||
pull_string(lp_iconv_convenience(global_loadparm), p, blob->data + ptr, p_len,
|
||||
pull_string(iconv_convenience, p, blob->data + ptr, p_len,
|
||||
len1, STR_ASCII|STR_NOALIGN);
|
||||
(*ps) = talloc_strdup(mem_ctx, p);
|
||||
if (!(*ps)) {
|
||||
@ -344,7 +348,7 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
head_ofs += pull_string(lp_iconv_convenience(global_loadparm), p,
|
||||
head_ofs += pull_string(iconv_convenience, p,
|
||||
blob->data+head_ofs, p_len,
|
||||
blob->length - head_ofs,
|
||||
STR_ASCII|STR_TERMINATE);
|
||||
|
@ -136,7 +136,9 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
|
||||
#endif
|
||||
|
||||
if (in.length) {
|
||||
if ((in.length < 16) || !msrpc_parse(out_mem_ctx, &in, "Cdd",
|
||||
if ((in.length < 16) || !msrpc_parse(out_mem_ctx,
|
||||
lp_iconv_convenience(gensec_security->lp_ctx),
|
||||
&in, "Cdd",
|
||||
"NTLMSSP",
|
||||
&ntlmssp_command,
|
||||
&neg_flags)) {
|
||||
@ -201,6 +203,7 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
|
||||
}
|
||||
|
||||
msrpc_gen(out_mem_ctx,
|
||||
lp_iconv_convenience(gensec_security->lp_ctx),
|
||||
&struct_blob, "aaaaa",
|
||||
NTLMSSP_NAME_TYPE_DOMAIN, target_name,
|
||||
NTLMSSP_NAME_TYPE_SERVER, gensec_ntlmssp_state->server_name,
|
||||
@ -221,6 +224,7 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
|
||||
}
|
||||
|
||||
msrpc_gen(out_mem_ctx,
|
||||
lp_iconv_convenience(gensec_security->lp_ctx),
|
||||
out, gen_string,
|
||||
"NTLMSSP",
|
||||
NTLMSSP_CHALLENGE,
|
||||
@ -278,6 +282,7 @@ static NTSTATUS ntlmssp_server_preauth(struct gensec_ntlmssp_state *gensec_ntlms
|
||||
|
||||
/* now the NTLMSSP encoded auth hashes */
|
||||
if (!msrpc_parse(gensec_ntlmssp_state,
|
||||
lp_iconv_convenience(gensec_ntlmssp_state->gensec_security->lp_ctx),
|
||||
&request, parse_string,
|
||||
"NTLMSSP",
|
||||
&ntlmssp_command,
|
||||
@ -304,6 +309,7 @@ static NTSTATUS ntlmssp_server_preauth(struct gensec_ntlmssp_state *gensec_ntlms
|
||||
|
||||
/* now the NTLMSSP encoded auth hashes */
|
||||
if (!msrpc_parse(gensec_ntlmssp_state,
|
||||
lp_iconv_convenience(gensec_ntlmssp_state->gensec_security->lp_ctx),
|
||||
&request, parse_string,
|
||||
"NTLMSSP",
|
||||
&ntlmssp_command,
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "lib/crypto/crypto.h"
|
||||
#include "auth/credentials/credentials.h"
|
||||
#include "auth/gensec/gensec.h"
|
||||
#include "param/param.h"
|
||||
|
||||
#define CLI_SIGN "session key to client-to-server signing key magic constant"
|
||||
#define CLI_SEAL "session key to client-to-server sealing key magic constant"
|
||||
@ -117,7 +118,9 @@ static NTSTATUS ntlmssp_make_packet_signature(struct gensec_ntlmssp_state *gense
|
||||
} else {
|
||||
uint32_t crc;
|
||||
crc = crc32_calc_buffer(data, length);
|
||||
if (!msrpc_gen(sig_mem_ctx, sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
|
||||
if (!msrpc_gen(sig_mem_ctx,
|
||||
lp_iconv_convenience(gensec_ntlmssp_state->gensec_security->lp_ctx),
|
||||
sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
gensec_ntlmssp_state->crypt.ntlm.seq_num++;
|
||||
@ -244,7 +247,9 @@ NTSTATUS gensec_ntlmssp_seal_packet(struct gensec_security *gensec_security,
|
||||
} else {
|
||||
uint32_t crc;
|
||||
crc = crc32_calc_buffer(data, length);
|
||||
if (!msrpc_gen(sig_mem_ctx, sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
|
||||
if (!msrpc_gen(sig_mem_ctx,
|
||||
lp_iconv_convenience(gensec_security->lp_ctx),
|
||||
sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, gensec_ntlmssp_state->crypt.ntlm.seq_num)) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,8 @@ DATA_BLOB NTLMv2_generate_names_blob(TALLOC_CTX *mem_ctx,
|
||||
{
|
||||
DATA_BLOB names_blob = data_blob_talloc(mem_ctx, NULL, 0);
|
||||
|
||||
msrpc_gen(mem_ctx, &names_blob, "aaa",
|
||||
msrpc_gen(mem_ctx, lp_iconv_convenience(global_loadparm), &names_blob,
|
||||
"aaa",
|
||||
NTLMSSP_NAME_TYPE_DOMAIN, domain,
|
||||
NTLMSSP_NAME_TYPE_SERVER, hostname,
|
||||
0, "");
|
||||
@ -321,7 +322,7 @@ static DATA_BLOB NTLMv2_generate_client_data(TALLOC_CTX *mem_ctx, const DATA_BLO
|
||||
|
||||
/* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */
|
||||
|
||||
msrpc_gen(mem_ctx, &response, "ddbbdb",
|
||||
msrpc_gen(mem_ctx, NULL, &response, "ddbbdb",
|
||||
0x00000101, /* Header */
|
||||
0, /* 'Reserved' */
|
||||
long_date, 8, /* Timestamp */
|
||||
|
Loading…
Reference in New Issue
Block a user