summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-07-20 13:35:43 -0700
committerJeremy Allison <jra@samba.org>2010-07-20 13:35:43 -0700
commit4ed9437b7e24365b9acd179b6553793db95a4c54 (patch)
treebe148ed36f2f057a596e366b35e5b99380b1d370 /source3/smbd
parentdc443ee6e9e97c08bcceaa1cbc155635e73e8118 (diff)
downloadsamba-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/smbd')
-rw-r--r--source3/smbd/seal.c4
-rw-r--r--source3/smbd/sesssetup.c21
-rw-r--r--source3/smbd/smb2_sesssetup.c11
3 files changed, 20 insertions, 16 deletions
diff --git a/source3/smbd/seal.c b/source3/smbd/seal.c
index 81b545aabf..2c7d97fd6d 100644
--- a/source3/smbd/seal.c
+++ b/source3/smbd/seal.c
@@ -497,7 +497,7 @@ static NTSTATUS srv_enc_spnego_negotiate(connection_struct *conn,
blob = data_blob_const(*ppdata, *p_data_size);
- status = parse_spnego_mechanisms(blob, &secblob, &kerb_mech);
+ status = parse_spnego_mechanisms(talloc_tos(), blob, &secblob, &kerb_mech);
if (!NT_STATUS_IS_OK(status)) {
return nt_status_squash(status);
}
@@ -507,7 +507,7 @@ static NTSTATUS srv_enc_spnego_negotiate(connection_struct *conn,
srv_free_encryption_context(&partial_srv_trans_enc_ctx);
if (kerb_mech) {
- SAFE_FREE(kerb_mech);
+ TALLOC_FREE(kerb_mech);
#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
status = srv_enc_spnego_gss_negotiate(ppdata, p_data_size, secblob);
diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c
index 5381122e2b..15cbcbfb9a 100644
--- a/source3/smbd/sesssetup.c
+++ b/source3/smbd/sesssetup.c
@@ -723,7 +723,8 @@ static void reply_spnego_ntlmssp(struct smb_request *req,
Is this a krb5 mechanism ?
****************************************************************************/
-NTSTATUS parse_spnego_mechanisms(DATA_BLOB blob_in,
+NTSTATUS parse_spnego_mechanisms(TALLOC_CTX *ctx,
+ DATA_BLOB blob_in,
DATA_BLOB *pblob_out,
char **kerb_mechOID)
{
@@ -734,7 +735,7 @@ NTSTATUS parse_spnego_mechanisms(DATA_BLOB blob_in,
*kerb_mechOID = NULL;
/* parse out the OIDs and the first sec blob */
- if (!spnego_parse_negTokenInit(blob_in, OIDs, NULL, pblob_out)) {
+ if (!spnego_parse_negTokenInit(ctx, blob_in, OIDs, NULL, pblob_out)) {
return NT_STATUS_LOGON_FAILURE;
}
@@ -751,7 +752,7 @@ NTSTATUS parse_spnego_mechanisms(DATA_BLOB blob_in,
#ifdef HAVE_KRB5
if (strcmp(OID_KERBEROS5, OIDs[0]) == 0 ||
strcmp(OID_KERBEROS5_OLD, OIDs[0]) == 0) {
- *kerb_mechOID = SMB_STRDUP(OIDs[0]);
+ *kerb_mechOID = talloc_strdup(ctx, OIDs[0]);
if (*kerb_mechOID == NULL) {
ret = NT_STATUS_NO_MEMORY;
}
@@ -802,7 +803,8 @@ static void reply_spnego_negotiate(struct smb_request *req,
NTSTATUS status;
struct smbd_server_connection *sconn = req->sconn;
- status = parse_spnego_mechanisms(blob1, &secblob, &kerb_mech);
+ status = parse_spnego_mechanisms(talloc_tos(),
+ blob1, &secblob, &kerb_mech);
if (!NT_STATUS_IS_OK(status)) {
/* Kill the intermediate vuid */
invalidate_vuid(sconn, vuid);
@@ -824,7 +826,7 @@ static void reply_spnego_negotiate(struct smb_request *req,
/* Kill the intermediate vuid */
invalidate_vuid(sconn, vuid);
}
- SAFE_FREE(kerb_mech);
+ TALLOC_FREE(kerb_mech);
return;
}
#endif
@@ -838,7 +840,7 @@ static void reply_spnego_negotiate(struct smb_request *req,
/* The mechtoken is a krb5 ticket, but
* we need to fall back to NTLM. */
reply_spnego_downgrade_to_ntlmssp(req, vuid);
- SAFE_FREE(kerb_mech);
+ TALLOC_FREE(kerb_mech);
return;
}
@@ -895,7 +897,8 @@ static void reply_spnego_auth(struct smb_request *req,
/* Might be a second negTokenTarg packet */
char *kerb_mech = NULL;
- status = parse_spnego_mechanisms(auth, &secblob, &kerb_mech);
+ status = parse_spnego_mechanisms(talloc_tos(),
+ auth, &secblob, &kerb_mech);
if (!NT_STATUS_IS_OK(status)) {
/* Kill the intermediate vuid */
@@ -918,7 +921,7 @@ static void reply_spnego_auth(struct smb_request *req,
/* Kill the intermediate vuid */
invalidate_vuid(sconn, vuid);
}
- SAFE_FREE(kerb_mech);
+ TALLOC_FREE(kerb_mech);
return;
}
#endif
@@ -934,7 +937,7 @@ static void reply_spnego_auth(struct smb_request *req,
"not enabled\n"));
reply_nterror(req, nt_status_squash(
NT_STATUS_LOGON_FAILURE));
- SAFE_FREE(kerb_mech);
+ TALLOC_FREE(kerb_mech);
}
}
diff --git a/source3/smbd/smb2_sesssetup.c b/source3/smbd/smb2_sesssetup.c
index a8172d3ee3..e8c69eaad5 100644
--- a/source3/smbd/smb2_sesssetup.c
+++ b/source3/smbd/smb2_sesssetup.c
@@ -553,7 +553,7 @@ static NTSTATUS smbd_smb2_spnego_negotiate(struct smbd_smb2_session *session,
/* Ensure we have no old NTLM state around. */
TALLOC_FREE(session->auth_ntlmssp_state);
- status = parse_spnego_mechanisms(in_security_buffer,
+ status = parse_spnego_mechanisms(talloc_tos(), in_security_buffer,
&secblob_in, &kerb_mech);
if (!NT_STATUS_IS_OK(status)) {
goto out;
@@ -618,7 +618,7 @@ static NTSTATUS smbd_smb2_spnego_negotiate(struct smbd_smb2_session *session,
data_blob_free(&secblob_in);
data_blob_free(&secblob_out);
data_blob_free(&chal_out);
- SAFE_FREE(kerb_mech);
+ TALLOC_FREE(kerb_mech);
if (!NT_STATUS_IS_OK(status) &&
!NT_STATUS_EQUAL(status,
NT_STATUS_MORE_PROCESSING_REQUIRED)) {
@@ -730,7 +730,8 @@ static NTSTATUS smbd_smb2_spnego_auth(struct smbd_smb2_session *session,
DATA_BLOB secblob_in = data_blob_null;
char *kerb_mech = NULL;
- status = parse_spnego_mechanisms(in_security_buffer,
+ status = parse_spnego_mechanisms(talloc_tos(),
+ in_security_buffer,
&secblob_in, &kerb_mech);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(session);
@@ -750,7 +751,7 @@ static NTSTATUS smbd_smb2_spnego_auth(struct smbd_smb2_session *session,
out_session_id);
data_blob_free(&secblob_in);
- SAFE_FREE(kerb_mech);
+ TALLOC_FREE(kerb_mech);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(session);
}
@@ -768,7 +769,7 @@ static NTSTATUS smbd_smb2_spnego_auth(struct smbd_smb2_session *session,
"not enabled\n"));
TALLOC_FREE(session);
data_blob_free(&secblob_in);
- SAFE_FREE(kerb_mech);
+ TALLOC_FREE(kerb_mech);
return NT_STATUS_LOGON_FAILURE;
}