summaryrefslogtreecommitdiff
path: root/source4/auth/kerberos
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-05-21 06:12:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:52:42 -0500
commit7bb939b1cb2b39a8271cf16d9f5fce5312a9af10 (patch)
tree3210fa30663556e6ff238a3c9f6d17a209bf26b4 /source4/auth/kerberos
parent042ddf28ec036141b2457eb4bf6d2b0cec5cc790 (diff)
downloadsamba-7bb939b1cb2b39a8271cf16d9f5fce5312a9af10.tar.gz
samba-7bb939b1cb2b39a8271cf16d9f5fce5312a9af10.tar.bz2
samba-7bb939b1cb2b39a8271cf16d9f5fce5312a9af10.zip
r23030: finally fixed up our asn1 code to use better memory allocation. This
should allow us to fix some long standing memory leaks. (This used to be commit 3db49c2ec9968221c1361785b94061046ecd159d)
Diffstat (limited to 'source4/auth/kerberos')
-rw-r--r--source4/auth/kerberos/gssapi_parse.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/source4/auth/kerberos/gssapi_parse.c b/source4/auth/kerberos/gssapi_parse.c
index cc9565a040..86a9e9554a 100644
--- a/source4/auth/kerberos/gssapi_parse.c
+++ b/source4/auth/kerberos/gssapi_parse.c
@@ -31,30 +31,28 @@
*/
DATA_BLOB gensec_gssapi_gen_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *ticket, const uint8_t tok_id[2])
{
- struct asn1_data data;
+ struct asn1_data *data = asn1_init(mem_ctx);
DATA_BLOB ret;
- if (!ticket->data) {
+ if (!data || !ticket->data) {
return data_blob(NULL,0);
}
- ZERO_STRUCT(data);
+ asn1_push_tag(data, ASN1_APPLICATION(0));
+ asn1_write_OID(data, GENSEC_OID_KERBEROS5);
- asn1_push_tag(&data, ASN1_APPLICATION(0));
- asn1_write_OID(&data, GENSEC_OID_KERBEROS5);
+ asn1_write(data, tok_id, 2);
+ asn1_write(data, ticket->data, ticket->length);
+ asn1_pop_tag(data);
- asn1_write(&data, tok_id, 2);
- asn1_write(&data, ticket->data, ticket->length);
- asn1_pop_tag(&data);
-
- if (data.has_error) {
- DEBUG(1,("Failed to build krb5 wrapper at offset %d\n", (int)data.ofs));
- asn1_free(&data);
+ if (data->has_error) {
+ DEBUG(1,("Failed to build krb5 wrapper at offset %d\n", (int)data->ofs));
+ asn1_free(data);
return data_blob(NULL,0);
}
- ret = data_blob_talloc(mem_ctx, data.data, data.length);
- asn1_free(&data);
+ ret = data_blob_talloc(mem_ctx, data->data, data->length);
+ asn1_free(data);
return ret;
}
@@ -65,29 +63,29 @@ DATA_BLOB gensec_gssapi_gen_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *tick
BOOL gensec_gssapi_parse_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, DATA_BLOB *ticket, uint8_t tok_id[2])
{
BOOL ret;
- struct asn1_data data;
+ struct asn1_data *data = asn1_init(mem_ctx);
int data_remaining;
- asn1_load(&data, *blob);
- asn1_start_tag(&data, ASN1_APPLICATION(0));
- asn1_check_OID(&data, GENSEC_OID_KERBEROS5);
+ asn1_load(data, *blob);
+ asn1_start_tag(data, ASN1_APPLICATION(0));
+ asn1_check_OID(data, GENSEC_OID_KERBEROS5);
- data_remaining = asn1_tag_remaining(&data);
+ data_remaining = asn1_tag_remaining(data);
if (data_remaining < 3) {
- data.has_error = True;
+ data->has_error = True;
} else {
- asn1_read(&data, tok_id, 2);
+ asn1_read(data, tok_id, 2);
data_remaining -= 2;
*ticket = data_blob_talloc(mem_ctx, NULL, data_remaining);
- asn1_read(&data, ticket->data, ticket->length);
+ asn1_read(data, ticket->data, ticket->length);
}
- asn1_end_tag(&data);
+ asn1_end_tag(data);
- ret = !data.has_error;
+ ret = !data->has_error;
- asn1_free(&data);
+ asn1_free(data);
return ret;
}
@@ -99,15 +97,15 @@ BOOL gensec_gssapi_parse_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, D
BOOL gensec_gssapi_check_oid(const DATA_BLOB *blob, const char *oid)
{
BOOL ret;
- struct asn1_data data;
+ struct asn1_data *data = asn1_init(NULL);
- asn1_load(&data, *blob);
- asn1_start_tag(&data, ASN1_APPLICATION(0));
- asn1_check_OID(&data, oid);
+ asn1_load(data, *blob);
+ asn1_start_tag(data, ASN1_APPLICATION(0));
+ asn1_check_OID(data, oid);
- ret = !data.has_error;
+ ret = !data->has_error;
- asn1_free(&data);
+ asn1_free(data);
return ret;
}