diff options
author | Jeremy Allison <jra@samba.org> | 2010-07-20 13:35:43 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2010-07-20 13:35:43 -0700 |
commit | 4ed9437b7e24365b9acd179b6553793db95a4c54 (patch) | |
tree | be148ed36f2f057a596e366b35e5b99380b1d370 /source3/libsmb | |
parent | dc443ee6e9e97c08bcceaa1cbc155635e73e8118 (diff) | |
download | samba-4ed9437b7e24365b9acd179b6553793db95a4c54.tar.gz samba-4ed9437b7e24365b9acd179b6553793db95a4c54.tar.bz2 samba-4ed9437b7e24365b9acd179b6553793db95a4c54.zip |
Add TALLOC_CTX argument to spnego_parse_negTokenInit, reduce
use of malloc, and data_blob().
Jeremy.
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/cliconnect.c | 4 | ||||
-rw-r--r-- | source3/libsmb/clispnego.c | 11 |
2 files changed, 8 insertions, 7 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index dc3f236609..86338d0ef3 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1225,7 +1225,7 @@ ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user, * negprot reply. It is WRONG to depend on the principal sent in the * negprot reply, but right now we do it. If we don't receive one, * we try to best guess, then fall back to NTLM. */ - if (!spnego_parse_negTokenInit(blob, OIDs, &principal, NULL)) { + if (!spnego_parse_negTokenInit(talloc_tos(), blob, OIDs, &principal, NULL)) { data_blob_free(&blob); return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER); } @@ -1248,6 +1248,7 @@ ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user, status = cli_set_username(cli, user); if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(principal); return ADS_ERROR_NT(status); } @@ -1299,6 +1300,7 @@ ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user, machine = SMB_STRDUP(cli->desthost); } if (machine == NULL) { + TALLOC_FREE(principal); return ADS_ERROR_NT(NT_STATUS_NO_MEMORY); } diff --git a/source3/libsmb/clispnego.c b/source3/libsmb/clispnego.c index cd09a3836f..0935041a34 100644 --- a/source3/libsmb/clispnego.c +++ b/source3/libsmb/clispnego.c @@ -91,7 +91,8 @@ DATA_BLOB spnego_gen_negTokenInit(const char *OIDs[], parse a negTokenInit packet giving a GUID, a list of supported OIDs (the mechanisms) and a principal name string */ -bool spnego_parse_negTokenInit(DATA_BLOB blob, +bool spnego_parse_negTokenInit(TALLOC_CTX *ctx, + DATA_BLOB blob, char *OIDs[ASN1_MAX_OIDS], char **principal, DATA_BLOB *secblob) @@ -124,7 +125,7 @@ bool spnego_parse_negTokenInit(DATA_BLOB blob, asn1_start_tag(data,ASN1_SEQUENCE(0)); for (i=0; asn1_tag_remaining(data) > 0 && i < ASN1_MAX_OIDS-1; i++) { const char *oid_str = NULL; - asn1_read_OID(data,talloc_autofree_context(),&oid_str); + asn1_read_OID(data,ctx,&oid_str); OIDs[i] = CONST_DISCARD(char *, oid_str); } OIDs[i] = NULL; @@ -162,8 +163,7 @@ bool spnego_parse_negTokenInit(DATA_BLOB blob, DATA_BLOB sblob = data_blob_null; /* mechToken [2] OCTET STRING OPTIONAL */ asn1_start_tag(data, ASN1_CONTEXT(2)); - asn1_read_OctetString(data, talloc_autofree_context(), - &sblob); + asn1_read_OctetString(data, ctx, &sblob); asn1_end_tag(data); if (secblob) { *secblob = sblob; @@ -178,8 +178,7 @@ bool spnego_parse_negTokenInit(DATA_BLOB blob, asn1_start_tag(data, ASN1_CONTEXT(3)); asn1_start_tag(data, ASN1_SEQUENCE(0)); asn1_start_tag(data, ASN1_CONTEXT(0)); - asn1_read_GeneralString(data,talloc_autofree_context(), - &princ); + asn1_read_GeneralString(data, ctx, &princ); asn1_end_tag(data); asn1_end_tag(data); asn1_end_tag(data); |