More conversions of NULL -> talloc_autofree_context()
[ira/wip.git] / source3 / libsmb / clikrb5.c
index 4ab31374e2c712627f521b5015ffeb390dc6628a..152c23bd150c39f679ef563c8a2fecde0b3ab2ae 100644 (file)
@@ -56,12 +56,12 @@ static krb5_error_code ads_krb5_get_fwd_ticket( krb5_context context,
        char *utf8_name;
        size_t converted_size;
 
-       if (!push_utf8_allocate(&utf8_name, name, &converted_size)) {
+       if (!push_utf8_talloc(talloc_tos(), &utf8_name, name, &converted_size)) {
                return ENOMEM;
        }
 
        ret = krb5_parse_name(context, utf8_name, principal);
-       SAFE_FREE(utf8_name);
+       TALLOC_FREE(utf8_name);
        return ret;
 }
 
@@ -79,24 +79,25 @@ static krb5_error_code smb_krb5_parse_name_norealm_conv(krb5_context context,
        size_t converted_size;
 
        *principal = NULL;
-       if (!push_utf8_allocate(&utf8_name, name, &converted_size)) {
+       if (!push_utf8_talloc(talloc_tos(), &utf8_name, name, &converted_size)) {
                return ENOMEM;
        }
 
        ret = krb5_parse_name_norealm(context, utf8_name, principal);
-       SAFE_FREE(utf8_name);
+       TALLOC_FREE(utf8_name);
        return ret;
 }
 #endif
 
 /**************************************************************
  krb5_parse_name that returns a UNIX charset name. Must
- be freed with normal free() call.
+ be freed with talloc_free() call.
 **************************************************************/
 
- krb5_error_code smb_krb5_unparse_name(krb5_context context,
-                                       krb5_const_principal principal,
-                                       char **unix_name)
+krb5_error_code smb_krb5_unparse_name(TALLOC_CTX *mem_ctx,
+                                     krb5_context context,
+                                     krb5_const_principal principal,
+                                     char **unix_name)
 {
        krb5_error_code ret;
        char *utf8_name;
@@ -108,7 +109,7 @@ static krb5_error_code smb_krb5_parse_name_norealm_conv(krb5_context context,
                return ret;
        }
 
-       if (!pull_utf8_allocate(unix_name, utf8_name, &converted_size)) {
+       if (!pull_utf8_talloc(mem_ctx, unix_name, utf8_name, &converted_size)) {
                krb5_free_unparsed_name(context, utf8_name);
                return ENOMEM;
        }
@@ -345,7 +346,7 @@ bool unwrap_edata_ntstatus(TALLOC_CTX *mem_ctx,
        }
        
        asn1_start_tag(data, ASN1_CONTEXT(2));
-       asn1_read_OctetString(data, NULL, &edata_contents);
+       asn1_read_OctetString(data, talloc_autofree_context(), &edata_contents);
        asn1_end_tag(data);
        asn1_end_tag(data);
        asn1_end_tag(data);
@@ -388,7 +389,7 @@ bool unwrap_pac(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, DATA_BLOB *unwrapped_
        
        asn1_end_tag(data);
        asn1_start_tag(data, ASN1_CONTEXT(1));
-       asn1_read_OctetString(data, NULL, &pac_contents);
+       asn1_read_OctetString(data, talloc_autofree_context(), &pac_contents);
        asn1_end_tag(data);
        asn1_end_tag(data);
        asn1_end_tag(data);
@@ -923,10 +924,15 @@ failed:
 
  krb5_error_code smb_krb5_kt_free_entry(krb5_context context, krb5_keytab_entry *kt_entry)
 {
-#if defined(HAVE_KRB5_KT_FREE_ENTRY)
-       return krb5_kt_free_entry(context, kt_entry);
-#elif defined(HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS)
+/* Try krb5_free_keytab_entry_contents first, since 
+ * MIT Kerberos >= 1.7 has both krb5_free_keytab_entry_contents and 
+ * krb5_kt_free_entry but only has a prototype for the first, while the 
+ * second is considered private. 
+ */
+#if defined(HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS)
        return krb5_free_keytab_entry_contents(context, kt_entry);
+#elif defined(HAVE_KRB5_KT_FREE_ENTRY)
+       return krb5_kt_free_entry(context, kt_entry);
 #else
 #error UNKNOWN_KT_FREE_FUNCTION
 #endif
@@ -1081,10 +1087,10 @@ get_key_from_keytab(krb5_context context,
        }
 
        if ( DEBUGLEVEL >= 10 ) {
-               if (smb_krb5_unparse_name(context, server, &name) == 0) {
+               if (smb_krb5_unparse_name(talloc_tos(), context, server, &name) == 0) {
                        DEBUG(10,("get_key_from_keytab: will look for kvno %d, enctype %d and name: %s\n", 
                                kvno, enctype, name));
-                       SAFE_FREE(name);
+                       TALLOC_FREE(name);
                }
        }